<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Desktop App</title>
    <link rel="shortcut icon" href="data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23673ab7' viewBox='0 0 16 16'%3E%3Cpath d='M6.375 7.125V4.658h1.78c.973 0 1.542.457 1.542 1.237 0 .802-.604 1.23-1.764 1.23zm0 3.762h1.898c1.184 0 1.81-.48 1.81-1.377 0-.885-.65-1.348-1.886-1.348H6.375z'/%3E%3Cpath d='M4.002 0a4 4 0 0 0-4 4v8a4 4 0 0 0 4 4h8a4 4 0 0 0 4-4V4a4 4 0 0 0-4-4zm1.06 12V3.545h3.399c1.587 0 2.543.809 2.543 2.11 0 .884-.65 1.675-1.483 1.816v.1c1.143.117 1.904.931 1.904 2.033 0 1.488-1.084 2.396-2.888 2.396z'/%3E%3C/svg%3E">
    <link rel="icon" href="data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23673ab7' viewBox='0 0 16 16'%3E%3Cpath d='M6.375 7.125V4.658h1.78c.973 0 1.542.457 1.542 1.237 0 .802-.604 1.23-1.764 1.23zm0 3.762h1.898c1.184 0 1.81-.48 1.81-1.377 0-.885-.65-1.348-1.886-1.348H6.375z'/%3E%3Cpath d='M4.002 0a4 4 0 0 0-4 4v8a4 4 0 0 0 4 4h8a4 4 0 0 0 4-4V4a4 4 0 0 0-4-4zm1.06 12V3.545h3.399c1.587 0 2.543.809 2.543 2.11 0 .884-.65 1.675-1.483 1.816v.1c1.143.117 1.904.931 1.904 2.033 0 1.488-1.084 2.396-2.888 2.396z'/%3E%3C/svg%3E">
    <link rel="stylesheet" href="https://fastly.jsdelivr.net/npm/bootstrap@3.3.6/dist/css/bootstrap.min.css" />
    <link rel="stylesheet" href="https://fastly.jsdelivr.net/npm/kindeditor@4.1.10/plugins/code/prettify.css" />
    <link rel="stylesheet" href="https://fastly.jsdelivr.net/npm/social-share.js@1.0.16/dist/css/share.min.css" />
    <style type="text/css">
        #loader{position:fixed;top:0;right:0;bottom:0;left:0;background-color:rgba(0,0,0,.3);z-index:99999}
        #loader .inner{position:absolute;top:0;right:0;bottom:0;left:0;width:240px;height:130px;margin:auto;padding-top:15px;text-align:center;color:#fff;background-color:rgba(0,0,0,.7);z-index:100;border-radius:15px}
        #carousel-example-generic>.carousel-inner>.item>a>img{max-height:150px}
        @media screen and (min-width:768px){#carousel-example-generic>.carousel-inner>.item>a>img{max-height:200px}}
        @media screen and (min-width:992px){#carousel-example-generic>.carousel-inner>.item>a>img{max-height:280px}}
        @media screen and (min-width:1200px){#carousel-example-generic>.carousel-inner>.item>a>img{max-height:380px}}
        .entry-content>*{margin:25px 0}
        .entry-content>.tts{margin:0;padding:0;border:0;border-radius:0;background-color:#fde6e0}
        .entry-content>div.tts,.entry-content>p.tts{margin:15px 0;padding:10px;border:1px solid #dcd6d6;border-radius:3px;background-color:#f9f2f4}
        #loading{margin:15px 0}
        #loading>.icon-loading{display:inline-block;width:1em;height:1em;border:3px solid #e5e5e5;border-top:3px solid #333;border-radius:50%;animation:turn-around 1.5s linear infinite}
        @-o-keyframes turn-around{from{-o-transform:rotate(0)}
        to{-o-transform:rotate(360deg)}
        }
        @-webkit-keyframes turn-around{from{-webkit-transform:rotate(0)}
        to{-webkit-transform:rotate(360deg)}
        }
        @-moz-keyframes turn-around{from{-moz-transform:rotate(0)}
        to{-moz-transform:rotate(360deg)}
        }
        @-ms-keyframes turn-around{from{-ms-transform:rotate(0)}
        to{-ms-transform:rotate(360deg)}
        }
        @keyframes turn-around{from{transform:rotate(0)}
        to{transform:rotate(360deg)}
        }
    </style>
</head>

<body>
    <div id="app"></div>
    <script src="https://fastly.jsdelivr.net/npm/jquery@1.12.3/dist/jquery.min.js"></script>
    <script src="https://fastly.jsdelivr.net/npm/bootstrap@3.3.6/dist/js/bootstrap.min.js"></script>
    <script src="https://fastly.jsdelivr.net/npm/kindeditor@4.1.10/plugins/code/prettify.js"></script>
    <script src="https://fastly.jsdelivr.net/npm/social-share.js@1.0.16/dist/js/social-share.min.js"></script>
    <script type="text/javascript">
        jQuery(document).ready(function ($) {
            // IE跨域兼容
            $.support.cors = true;
            var render = {
                api: document.domain.match(/localhost|127.0.0.1/i) ? '/' : (document.location.protocol == 'https:' ? 'https://yesu.co/' : 'http://yesu.co/'),
                path: '/',
                url: '',
                lang: window.localStorage ? localStorage.getItem('multiLang') || 'zh-CN' : 'zh-CN',
                token: window.localStorage ? localStorage.getItem('webToken') || '' : '',
                langs: ['co', 'gn', 'rw', 'ha', 'no', 'af', 'yo', 'en', 'gom', 'la', 'ne', 'fr', 'cs', 'haw', 'ka', 'ru', 'zh-CN', 'fa', 'bho', 'hi', 'be', 'sw', 'is', 'yi', 'ak', 'ga', 'gu', 'km', 'sk', 'iw', 'kn', 'hu', 'ta', 'ar', 'bn', 'az', 'sm', 'su', 'da', 'sn', 'bm', 'lt', 'vi', 'mt', 'tk', 'as', 'ca', 'si', 'ceb', 'gd', 'sa', 'pl', 'gl', 'lv', 'uk', 'tt', 'cy', 'ja', 'tl', 'ay', 'lo', 'te', 'ro', 'ht', 'doi', 'sv', 'mai', 'th', 'hy', 'my', 'ps', 'hmn', 'dv', 'zh-TW', 'lb', 'sd', 'ku', 'tr', 'mk', 'bg', 'ms', 'lg', 'mr', 'et', 'ml', 'de', 'sl', 'ur', 'pt', 'ig', 'ckb', 'om', 'el', 'es', 'fy', 'so', 'am', 'ny', 'pa', 'eu', 'it', 'sq', 'ko', 'tg', 'fi', 'ky', 'ee', 'hr', 'qu', 'bs', 'mi', 'or', 'ti', 'kk', 'nl', 'kri', 'ln', 'mg', 'mn', 'lus', 'xh', 'zu', 'sr', 'nso', 'st', 'eo', 'mni-Mtei', 'ug', 'uz', 'ilo', 'id', 'jw', 'ts'],
                data: null,
                // 语音朗读
                stopped: true,
                audio: new Audio(),
                audioArray: [],
                textArray: [],
                nodes: [],
                speechInstance: null,
                offLine: false,
                ttsApi: '',
                playErrors: 0,
                playErrorTimer: null,
                // 定时器
                timer: null,
                affixTop: 0,
                docHeight: 0,
                init: function () {
                    $(window).on('hashchange', render.router);
                    $(window).on('load', render.router);
                },

                // 哈希路由
                router: function () {
                    var hash = location.hash.replace('#', '');
                    render.path = hash === '' ? '/' : hash;
                    render.url = render.api + 'api' + render.path;
                    var parts = render.path.split('/');
                    if (render.langs.indexOf(parts[1]) !== -1) {
                        render.lang = parts[1];
                        parts[0] = parts[1];
                        parts[1] = 'api';
                        render.url = render.api + parts.join('/');
                    }
                    $.ajax({
                        url: render.url,
                        type: 'GET',
                        dataType: 'json',
                        data: { token: render.token },
                        beforeSend: render.beforeSend,
                        success: render.success,
                        error: render.error,
                    });
                },

                // 本地存储
                getItem: function (name) {
                    try {
                        if (window.localStorage) return localStorage.getItem(name);
                        return false;
                    } catch (e) {
                        render.removeItem(name);
                    }
                },
                setItem: function (name, value) {
                    window.localStorage && localStorage.setItem(name, value);
                },
                removeItem: function (name) {
                    window.localStorage && localStorage.removeItem(name);
                },

                // 路由到页面
                success: function (res) {
                    if (!res || res.code || (res.data && res.data.is_404)) {
                        return $('#app').html(render.err404());
                    }
                    render.data = res.data;
                    $('html').attr('lang', render.data.lang);
                    document.title = render.data.header.title.join('-');
                    var arr = [];
                    var pos = render.path.indexOf('#');
                    arr.push(render.header(render.data));
                    arr.push(render[render.data.action](render.data));
                    arr.push(render.footer(render.data));
                    $('#app').html(arr.join('\n')).parent().parent().stop().animate({
                        scrollTop: (pos !== -1 ? $(render.path.substr(pos)).offset().top : 0)
                    }, render.load);
                },

                // Err404页面
                err404: function () {
                    var arr = [];
                    arr.push('<div class="container" style="max-width:480px;margin:25px auto;">\n');
                    arr.push('\t<div class="row">\n');
                    arr.push('\t\t<div class="col-md-12">\n');
                    arr.push('\t\t\t<h1>404 Not found <span>:(</span></h1>\n');
                    arr.push('\t\t\t<p>Sorry, but the page you were trying to view does not exist.</p>\n');
                    arr.push('\t\t\t<p>It looks like this was the result of either:</p>\n');
                    arr.push('\t\t\t<ul>\n');
                    arr.push('\t\t\t\t<li>a mistyped address</li>\n');
                    arr.push('\t\t\t\t<li>an out-of-date link</li>\n');
                    arr.push('\t\t\t</ul>\n');
                    arr.push('\t\t\t<p>\n');
                    arr.push('\t\t\t\t<a href="javascript:history.go(-1);" title="Previous page">Previous page</a> &nbsp;\n');
                    arr.push('\t\t\t\t<a href="#/' + (render.lang === 'zh-CN' ? '' : render.lang + '/') + '" title="Back to home">Back to home</a>\n');
                    arr.push('\t\t\t</p>\n');
                    arr.push('\t\t</div>\n');
                    arr.push('\t</div>\n');
                    arr.push('</div>\n');
                    return arr.join('');
                },

                // 公共头部
                header: function (data) {
                    var arr = [];
                    arr.push('<nav class="navbar navbar-default navbar-static-top">\n');
                    arr.push('\t<div class="container">\n');
                    if (!data.is_detail && !data.is_page) arr.push('\t\t<h1 class="hidden">' + data.setting.webName + '</h1>\n');
                    arr.push('\t\t<div class="navbar-header">\n');
                    arr.push('\t\t\t<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">\n');
                    arr.push('\t\t\t\t<span class="sr-only">Toggle navigation</span>\n');
                    arr.push('\t\t\t\t<span class="icon-bar"></span>\n');
                    arr.push('\t\t\t\t<span class="icon-bar"></span>\n');
                    arr.push('\t\t\t\t<span class="icon-bar"></span>\n');
                    arr.push('\t\t\t\n');
                    arr.push('\t\t\t</button>\n');
                    arr.push('\t\t\t<a class="navbar-brand" href="#/' + (data.lang == 'zh-CN' ? '' : data.lang + '/') + '" title="' + data.setting.webName + '">' + (data.setting.webLogo ? '<img src="' + data.setting.webLogo + '" width="20" height="20" alt="' + data.setting.webName + '" title="' + data.setting.webName + '" />' : data.setting.webName) + '</a>\n');
                    arr.push('\t\t</div>\n');
                    arr.push('\t\t<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">\n');
                    arr.push('\t\t\t<ul class="nav navbar-nav">\n');
                    arr.push('\t\t\t\t<li' + (data.category_id == 0 && data.page_id == 0 ? ' class="active"' : '') + '><a href="#/' + (data.lang == 'zh-CN' ? '' : data.lang + '/') + '" title="' + (data.localize.home ? data.localize.home : '首页') + '">' + (data.localize.home ? data.localize.home : '首页') + '<span class="sr-only">(current)</span></a></li>\n');
                    // 分类导航
                    data.header.nav.forEach(function (item) {
                        if (item.children.length) {
                            arr.push('\t\t\t\t<li class="dropdown">\n');
                            arr.push('\t\t\t\t\t<a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">' + item.name + ' <span class="caret"></span></a>\n');
                            arr.push('\t\t\t\t\t<ul class="dropdown-menu">\n');
                            item.children.forEach(function (children) {
                                arr.push('\t\t\t\t\t\t<li><a href="#' + children.link + '" title="' + children.name + '">' + children.name + '</a></li>\n');
                                if (children.children.length) {
                                    arr.push('\t\t\t\t\t\t<li role="separator" class="divider"></li>\n');
                                    children.children.forEach(function (child) {
                                        arr.push('\t\t\t\t\t\t<li><a href="#' + child.link + '" title="' + child.name + '">' + child.name + '</a></li>\n');
                                    });
                                }
                            });
                            arr.push('\t\t\t\t\t</ul>\n');
                            arr.push('\t\t\t\t</li>\n');
                        } else {
                            arr.push('\t\t\t\t<li' + (item.id == data.category_id ? ' class="active"' : '') + '><a href="#' + item.link + '" title="' + item.name + '">' + item.name + '</a></li>\n');
                        }
                    });
                    // 页面导航
                    data.header.page_nav.forEach(function (item) {
                        if (item.children.length) {
                            arr.push('\t\t\t\t<li class="dropdown">\n');
                            arr.push('\t\t\t\t\t<a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">' + item.name + ' <span class="caret"></span></a>\n');
                            arr.push('\t\t\t\t\t<ul class="dropdown-menu">\n');
                            item.children.forEach(function (children) {
                                arr.push('\t\t\t\t\t\t<li' + (children.id == data.page_id ? ' class="active"' : '') + '><a href="#' + children.link + '" title="' + children.name + '">' + children.name + '</a></li>\n');
                                if (children.children.length) {
                                    arr.push('\t\t\t\t\t\t<li role="separator" class="divider"></li>\n');
                                    children.children.forEach(function (child) {
                                        arr.push('\t\t\t\t\t\t<li' + (child.id == data.page_id ? ' class="active"' : '') + '><a href="#' + child.link + '" title="' + child.name + '">' + child.name + '</a></li>\n');
                                    });
                                }
                            });
                            arr.push('\t\t\t\t\t</ul>\n');
                            arr.push('\t\t\t\t</li>\n');
                        } else {
                            arr.push('\t\t\t\t<li' + (item.id == data.page_id ? ' class="active"' : '') + '><a href="#' + item.link + '" title="' + item.name + '">' + item.name + '</a></li>\n');
                        }
                    });
                    // 多语切换
                    if (data.langs && data.langs.length) {
                        arr.push('\t\t\t\t<li class="dropdown">\n');
                        arr.push('\t\t\t\t\t<a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">' + (data.localize.language ? data.localize.language : '语言') + ' <span class="caret"></span></a>\n');
                        arr.push('\t\t\t\t\t<ul class="dropdown-menu dropdown-language" style="max-height:450px;overflow-y:scroll;">\n');
                        data.langs.forEach(function (_lang) {
                            arr.push('\t\t\t\t\t\t<li' + (_lang.slug == data.lang ? ' class="active"' : '') + '><a href="javascript:;" class="multilang" data-slug="' + _lang.slug + '" title="' + _lang.name + '（' + _lang.title + '）">' + _lang.name + '（' + _lang.title + '）</a></li>\n');
                        });
                        arr.push('\t\t\t\t\t</ul>\n');
                        arr.push('\t\t\t\t</li>\n');
                    }
                    arr.push('\t\t\t</ul>\n');
                    // 顶部搜索
                    arr.push('\t\t\t<div class="navbar-form navbar-right">\n');
                    arr.push('\t\t\t\t<form class="form-group search-form">\n');
                    arr.push('\t\t\t\t\t<div class="input-group">\n');
                    arr.push('\t\t\t\t\t\t<input type="text" class="form-control" placeholder="' + (data.localize.search ? data.localize.search : '搜索') + '..." name="q" value="' + data.q + '" required="required" />\n');
                    arr.push('\t\t\t\t\t\t<span class="input-group-btn">\n');
                    arr.push('\t\t\t\t\t\t\t<button type="submit" class="btn btn-default"><i class="glyphicon glyphicon-search"></i></button>\n');
                    arr.push('\t\t\t\t\t\t</span>\n');
                    arr.push('\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t</form>\n');
                    arr.push('\t\t\t</div>\n');
                    arr.push('\t\t</div>\n');
                    arr.push('\t</div>\n');
                    arr.push('</nav>\n');
                    // 面包屑导航
                    arr.push('<div class="container">\n');
                    arr.push('\t<div class="row">\n');
                    arr.push('\t\t<div class="col-md-12">\n');
                    arr.push('\t\t\t<ol class="breadcrumb">\n');
                    data.header.crumbs.forEach(function (item, i) {
                        if (i == data.header.crumbs.length - 1) {
                            arr.push('\t\t\t\t<li class="active">' + item.name + '</li>\n');
                        } else {
                            arr.push('\t\t\t\t<li><a href="#' + item.link + '" title="' + item.name + '">' + item.name + '</a></li>\n');
                        }
                    });
                    arr.push('\t\t\t</ol>\n');
                    arr.push('\t\t</div>\n');
                    arr.push('\t</div>\n');
                    arr.push('</div>\n');
                    return arr.join('');
                },

                // 侧边栏
                sidebar: function (data) {
                    var arr = [];
                    arr.push('<div class="col-md-4">\n');
                    // 语言切换
                    if (data.langs && data.langs.length) {
                        arr.push('\t<div class="panel panel-default">\n');
                        arr.push('\t\t<div class="panel-heading">\n');
                        arr.push('\t\t\t<h3 class="panel-title">' + (data.localize.language ? data.localize.language : '语言') + '</h3>\n');
                        arr.push('\t\t</div>\n');
                        arr.push('\t\t<div class="panel-body">\n');
                        arr.push('\t\t\t<div class="form-inline" style="margin-bottom:15px;">\n');
                        arr.push('\t\t\t\t<div class="form-group select-language">\n');
                        arr.push('\t\t\t\t\t<a class="multilang" data-slug="en" href="javascript:;">English</a> | <a class="multilang" data-slug="zh-CN" href="javascript:;" class="ignore">简体中文</a> | <a class="multilang" data-slug="zh-TW" href="javascript:;">繁體中文</a>\n');
                        arr.push('\t\t\t\t</div>\n');
                        arr.push('\t\t\t</div>\n');
                        arr.push('\t\t\t<div class="form-horizontal" style="padding:0 15px;">\n');
                        arr.push('\t\t\t\t<div class="form-group">\n');
                        arr.push('\t\t\t\t\t<label for="selectLanguage">' + (data.localize.choose_language ? data.localize.choose_language : '选择语言') + ':</label>\n');
                        arr.push('\t\t\t\t\t<select id="selectLanguage" class="selectLanguage form-control" size="0" onmousedown="if(this.options.length>11){this.size=12}" onblur="this.size=0" onchange="this.size=0">\n');
                        data.langs.forEach(function (_lang) {
                            arr.push('\t\t\t\t\t\t<option class="multilang" data-slug="' + _lang.slug + '" value="' + _lang.slug + '"' + (_lang.slug == data.lang ? ' selected' : '') + '>' + _lang.name + '（' + _lang.title + '）</option>\n');
                        });
                        arr.push('\t\t\t\t\t</select>\n');
                        arr.push('\t\t\t\t</div>\n');
                        arr.push('\t\t\t</div>\n');
                        arr.push('\t\t</div>\n');
                        arr.push('\t</div>\n');
                    }
                    // 分类目录
                    arr.push('\t<div class="panel panel-default">\n');
                    arr.push('\t\t<div class="panel-heading">\n');
                    arr.push('\t\t\t<h3 class="panel-title">' + data.aside.categories.title + '</h3>\n');
                    arr.push('\t\t</div>\n');
                    arr.push('\t\t<div class="panel-body">\n');
                    arr.push('\t\t\t<div class="list-group">\n');
                    if (data.aside.categories.list.length) {
                        data.aside.categories.list.forEach(function (item) {
                            if (parseInt(item.num)) {
                                arr.push('\t\t\t\t<a href="#' + item.link + '" title="' + item.name + '" class="list-group-item' + (item.id == data.category_id ? ' active' : '') + '"><span class="badge">' + item.num + '</span>' + item.name + '</a>\n');
                            }
                        });
                    } else {
                        arr.push('\t\t\t<p class="text-muted">' + (data.localize.no_category ? data.localize.no_category : '还没有分类') + '</p>\n');
                    }
                    arr.push('\t\t\t</div>\n');
                    arr.push('\t\t</div>\n');
                    arr.push('\t</div>\n');
                    // 页面
                    if (data.aside.pages.list.length) {
                        arr.push('\t<div class="panel panel-default panel-pages">\n');
                        arr.push('\t\t<div class="panel-heading">\n');
                        arr.push('\t\t\t<h3 class="panel-title">' + data.aside.pages.title + '</h3>\n');
                        arr.push('\t\t</div>\n');
                        arr.push('\t\t<div class="panel-body">\n');
                        arr.push('\t\t\t<div class="list-group">\n');
                        data.aside.pages.list.forEach(function (item) {
                            if (parseInt(item.pid)) {
                                arr.push('\t\t\t\t<a href="#' + item.link + '" data-slug="' + item.slug + '" data-id="' + item.id + '" title="' + item.name + '" class="list-group-item' + (item.id == data.page_id ? ' active' : '') + '"><span class="badge"></span>' + item.name + '</a>\n');
                            }
                        });
                        arr.push('\t\t\t</div>\n');
                        arr.push('\t\t</div>\n');
                        arr.push('\t</div>\n');
                    }
                    // 标签
                    arr.push('\t<div class="panel panel-default">\n');
                    arr.push('\t\t<div class="panel-heading">\n');
                    arr.push('\t\t\t<h3 class="panel-title">' + data.aside.tags.title + '</h3>\n');
                    arr.push('\t\t</div>\n');
                    arr.push('\t\t<div class="panel-body">\n');
                    if (data.aside.tags.list.length) {
                        data.aside.tags.list.forEach(function (item, i) {
                            arr.push('\t\t\t<a class="label label-' + (i % 6 == 0 ? 'primary' : (i % 6 == 1 ? 'success' : (i % 6 == 2 ? 'info' : (i % 6 == 3 ? 'warning' : (i % 6 == 4 ? 'danger' : (i % 6 == 5 ? 'default' : 'primary')))))) + '" href="#' + item.link + '" title="' + item.name + ' (' + item.num + ' ' + (data.localize.articles ? data.localize.articles : '篇文章') + ')" rel="nofollow">' + item.name + '(' + item.num + ')</a>\n');
                        });
                    } else {
                        arr.push('\t\t\t<p class="text-muted">' + (data.localize.no_tag ? data.localize.no_tag : '还没有标签') + '</p>\n');
                    }
                    arr.push('\t\t</div>\n');
                    arr.push('\t</div>\n');
                    // 热门文章
                    arr.push('\t<div class="panel panel-default">\n');
                    arr.push('\t\t<div class="panel-heading">\n');
                    arr.push('\t\t\t<h3 class="panel-title">' + data.aside.hot.title + '</h3>\n');
                    arr.push('\t\t</div>\n');
                    arr.push('\t\t<div class="panel-body">\n');
                    arr.push('\t\t\t<div class="list-group">\n');
                    if (data.aside.hot.list.length) {
                        data.aside.hot.list.forEach(function (item) {
                            arr.push('\t\t\t\t<a href="#' + item.link + '"' + (item.id == data.article_id ? ' rel="nofollow"' : '') + ' title="' + item.title + '" class="list-group-item' + (item.id == data.article_id ? ' active' : '') + '"><span class="badge">' + item.likes + '</span><span class="glyphicon glyphicon-fire' + (item.id != data.article_id ? ' text-muted' : '') + '" aria-hidden="true"></span> ' + item.title + '</a>\n');
                        });
                    } else {
                        arr.push('\t\t\t\t<p class="text-muted">' + (data.localize.no_hot ? data.localize.no_hot : '还没有热门') + '</p>\n')
                    }
                    arr.push('\t\t\t</div>\n');
                    arr.push('\t\t</div>\n');
                    arr.push('\t</div>\n');
                    // 本类更新
                    if (data.is_detail || data.is_category) {
                        arr.push('\t<div class="panel panel-default" id="panel-affix">\n');
                        arr.push('\t\t<div class="panel-heading">\n');
                        arr.push('\t\t\t<h3 class="panel-title">' + data.aside.self.title + '</h3>\n');
                        arr.push('\t\t</div>\n');
                        arr.push('\t\t<div class="panel-body">\n');
                        // 搜索框
                        arr.push('\t\t\t<div class="row">\n');
                        arr.push('\t\t\t\t<div class="col-md-12">\n');
                        arr.push('\t\t\t\t\t<form class="form-group search-form">\n');
                        arr.push('\t\t\t\t\t\t<div class="input-group">\n');
                        arr.push('\t\t\t\t\t\t\t<input type="text" class="form-control" name="q" value="' + data.q + '" placeholder="Search for..." required="required" />\n');
                        arr.push('\t\t\t\t\t\t\t<span class="input-group-btn">\n');
                        arr.push('\t\t\t\t\t\t\t\t<button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></button>\n');
                        arr.push('\t\t\t\t\t\t\t</span>\n');
                        arr.push('\t\t\t\t\t\t</div>\n');
                        arr.push('\t\t\t\t\t</form>\n');
                        arr.push('\t\t\t\t</div>\n');
                        arr.push('\t\t\t</div>\n');
                        arr.push('\t\t\t<div class="row">\n');
                        arr.push('\t\t\t\t<div class="col-md-12">\n');
                        arr.push('\t\t\t\t\t<div class="list-group">\n');
                        if (data.aside.self.list.length) {
                            data.aside.self.list.forEach(function (item, i) {
                                arr.push('\t\t\t\t\t\t<a href="#' + item.link + '"' + (item.id == data.article_id ? ' rel="nofollow"' : '') + ' title="' + item.title + '" class="list-group-item' + (item.id == data.article_id ? ' active' : '') + (i > 9 ? ' hidden' : '') + '">' + ((item.likes && item.update_at * 1000 > +new Date() - 24 * 3600 * 30 * 1000) || item.likes > 99 ? '<span class="badge">Hot</span>' : '') + '<span class="glyphicon glyphicon-list-alt' + (item.id != data.article_id ? ' text-muted' : '') + '" aria-hidden="true"></span> ' + item.title + '</a>\n');
                                if (i == data.aside.self.list.length - 1 && i > 9) {
                                    arr.push('\t\t\t\t\t\t<nav aria-label="Page navigation">\n');
                                    arr.push('\t\t\t\t\t\t\t<ul class="pager pager-list" data-index="0">\n');
                                    arr.push('\t\t\t\t\t\t\t\t<li class="disabled" data-type="prev"><a href="javascript:;" title="Previous">Previous</a></li>\n');
                                    arr.push('\t\t\t\t\t\t\t\t<li data-type="next"><a href="javascript:;" title="Next">Next</a></li>\n');
                                    arr.push('\t\t\t\t\t\t\t\t<li data-type="all"><a href="javascript:;" title="All">All</a></li>\n');
                                    arr.push('\t\t\t\t\t\t\t</ul>\n');
                                    arr.push('\t\t\t\t\t\t</nav>\n');
                                }
                            });
                        } else {
                            arr.push('\t\t\t\t\t\t<p class="text-muted">' + (data.localize.no_update ? data.localize.no_update : '还没有更新') + '</p>\n');
                        }
                        arr.push('\t\t\t\t\t</div>\n');
                        arr.push('\t\t\t\t</div>\n');
                        arr.push('\t\t\t</div>\n');
                        arr.push('\t\t</div>\n');
                        arr.push('\t</div>\n');
                    }
                    // 首页评论
                    if (data.is_index) {
                        arr.push('\t<div class="panel panel-default">\n');
                        arr.push('\t\t<div class="panel-heading">\n');
                        arr.push('\t\t\t<h3 class="panel-title">' + data.aside.comment.title + '</h3>\n');
                        arr.push('\t\t</div>\n');
                        arr.push('\t\t<div class="panel-body">\n');
                        if (data.aside.comment.list.length) {
                            data.aside.comment.list.forEach(function (item, i) {
                                arr.push('\t\t\t<div class="media">\n');
                                arr.push('\t\t\t\t<a href="#' + item.article_link + '#comments" title="' + item.article_title + '">\n');
                                arr.push('\t\t\t\t\t<div class="media-left">\n');
                                arr.push('\t\t\t\t\t\t<img class="media-object img-circle avatar" style="width: 64px;height: 64px;background-color: #f1f1f1;" src="" data-src="' + (item.avatar ? item.avatar : '') + '" alt="' + (item.nickname ? item.nickname : (data.localize.anonymous ? data.localize.anonymous : '匿名')) + '" title="' + (item.nickname ? item.nickname : (data.localize.anonymous ? data.localize.anonymous : '匿名')) + '" />\n');
                                arr.push('\t\t\t\t\t</div>\n');
                                arr.push('\t\t\t\t\t<div class="media-body">\n');
                                arr.push('\t\t\t\t\t\t<h4 class="media-heading"><strong>' + (item.nickname ? item.nickname : (data.localize.anonymous ? data.localize.anonymous : '匿名')) + '</strong> <cite>' + (data.localize.say ? data.localize.say : '说道') + '：</cite></h4>\n');
                                arr.push('\t\t\t\t\t\t<span class="text-muted">' + render.cutstr(item.comment.replace(/<[^>]*>/g, ' ').replace(/\s+/, ' '), 70) + '</span>\n');
                                arr.push('\t\t\t\t\t</div>\n');
                                arr.push('\t\t\t\t</a>\n');
                                arr.push('\t\t\t</div>\n');
                                if (i != data.aside.comment.list.length - 1) {
                                    arr.push('\t\t\t<hr>\n');
                                }
                            });
                        } else {
                            arr.push('\t\t\t<p class="text-muted">' + (data.localize.no_comment ? data.localize.no_comment : '还没有评论') + '</p>\n');
                        }
                        arr.push('\t\t</div>\n');
                        arr.push('\t</div>\n');
                    }
                    arr.push('</div>\n');
                    return arr.join('');
                },

                // 列表项目
                list: function (data) {
                    var arr = [];
                    arr.push('<div class="panel panel-default">\n');
                    if (!data.is_category && !data.is_detail) {
                        arr.push('\t<div class="panel-heading">' + data.main.title + '</div>\n');
                    }
                    arr.push('\t<div class="panel-body">\n');
                    if (data.main.list.length) {
                        data.main.list.forEach(function (item) {
                            arr.push('\t\t<div class="row">\n');
                            arr.push('\t\t\t<div class="col-md-12">\n');
                            arr.push('\t\t\t\t<div class="panel panel-default">\n');
                            arr.push('\t\t\t\t\t<div class="panel-body">\n');
                            arr.push('\t\t\t\t\t\t<div class="row">\n');
                            if (item.cover) {
                                arr.push('\t\t\t\t\t\t\t<div class="col-sm-3 col-md-3">\n');
                                arr.push('\t\t\t\t\t\t\t\t<a class="thumbnail" href="#' + item.link + '" title="' + item.title + '"><img style="width:100%;max-height:100px;background-color:#f1f1f1;" src="" data-src="' + item.cover + '" alt="' + item.title + '" title="' + item.title + '" /></a>\n');
                                arr.push('\t\t\t\t\t\t\t</div>\n');
                            }
                            arr.push('\t\t\t\t\t\t\t<div class="' + (item.cover ? 'col-sm-9 col-md-9' : 'col-sm-12 col-md-12') + '">\n');
                            arr.push('\t\t\t\t\t\t\t\t<h2 style="margin-top: 0;">\n');
                            arr.push('\t\t\t\t\t\t\t\t\t<a href="#' + item.link + '" title="' + item.title + '">' + item.title + '</a>\n');
                            if (item.update_at * 1000 > +new Date() - 24 * 3600 * 3 * 1000) {
                                arr.push('\t\t\t\t\t\t\t\t\t<span class="label label-success">New</span>\n');
                            }
                            if ((item.likes && item.update_at * 1000 > +new Date() - 24 * 3600 * 30 * 1000) || item.likes > 99) {
                                arr.push('\t\t\t\t\t\t\t\t\t<span class="label label-danger">Hot</span>\n');
                            }
                            arr.push('\t\t\t\t\t\t\t\t</h2>\n');
                            arr.push('\t\t\t\t\t\t\t\t<p>' + (item.description ? item.description : render.cutstr(item.content.replace(/<[^>]*>/g, ' ').replace(/\s+/g, ' '), 140)) + '</p>\n');
                            arr.push('\t\t\t\t\t\t\t\t<p>\n');
                            arr.push('\t\t\t\t\t\t\t\t\t<a href="#' + item.link + '" title="Read more" rel="nofollow" class="btn btn-primary pull-right" role="button"><span class="glyphicon glyphicon-link" aria-hidden="true"></span> Read more</a>\n');
                            arr.push('\t\t\t\t\t\t\t\t\t<span class="glyphicon glyphicon-time text-muted" aria-hidden="true"></span>\n');
                            var t = new Date(item.create_at * 1000);
                            var y = '' + t.getFullYear();
                            var m = ('0' + (t.getMonth() + 1)).slice(-2);
                            var d = ('0' + t.getDate()).slice(-2);
                            arr.push('\t\t\t\t\t\t\t\t\t<span class="text-muted">' + (m + '/' + d + '/' + y.slice(-2)) + '</span> &nbsp;\n');
                            arr.push('\t\t\t\t\t\t\t\t\t<span class="glyphicon glyphicon-eye-open text-muted" aria-hidden="true"></span>\n');
                            arr.push('\t\t\t\t\t\t\t\t\t<span class="text-muted">' + item.views + '</span>\n');
                            arr.push('\t\t\t\t\t\t\t\t</p>\n');
                            arr.push('\t\t\t\t\t\t\t</div>\n');
                            arr.push('\t\t\t\t\t\t</div>\n');
                            arr.push('\t\t\t\t\t</div>\n');
                            arr.push('\t\t\t\t</div>\n');
                            arr.push('\t\t\t</div>\n');
                            arr.push('\t\t</div>\n');
                        });
                    } else {
                        arr.push('\t\t<div class="row">\n');
                        arr.push('\t\t\t<div class="col-md-12">\n');
                        arr.push('\t\t\t\t<p class="text-center text-muted">' + (data.localize.no_article ? data.localize.no_article : '还没有文章') + '</p>\n');
                        arr.push('\t\t\t</div>\n');
                        arr.push('\t\t</div>\n');
                    }
                    // 分页
                    if (parseInt(data.main.count)) {
                        arr.push(render.pager(data));
                    }
                    arr.push('\t</div>\n');
                    arr.push('</div>\n');
                    return arr.join('');
                },

                // 页面列表
                list_page: function (data) {
                    var arr = [];
                    arr.push('<div class="panel panel-default">\n');
                    arr.push('\t<div class="panel-body">\n');
                    if (data.main.list.length) {
                        data.main.list.forEach(function (item) {
                            arr.push('\t\t<div class="row">\n');
                            arr.push('\t\t\t<div class="col-md-12">\n');
                            arr.push('\t\t\t\t<div class="panel panel-default">\n');
                            arr.push('\t\t\t\t\t<div class="panel-body">\n');
                            arr.push('\t\t\t\t\t\t<div class="row">\n');
                            if (item.cover) {
                                arr.push('\t\t\t\t\t\t\t<div class="col-sm-3 col-md-3">\n');
                                arr.push('\t\t\t\t\t\t\t\t<a class="thumbnail" href="#' + item.link + '" title="' + item.title + '"><img style="width:100%;max-height:100px;background-color:#f1f1f1;" src="" data-src="' + item.cover + '" alt="' + item.title + '" title="' + item.title + '" /></a>\n');
                                arr.push('\t\t\t\t\t\t\t</div>\n');
                            }
                            arr.push('\t\t\t\t\t\t\t<div class="' + (item.cover ? 'col-sm-9 col-md-9' : 'col-sm-12 col-md-12') + '">\n');
                            arr.push('\t\t\t\t\t\t\t\t<h2 style="margin-top: 0;">\n');
                            arr.push('\t\t\t\t\t\t\t\t\t<a href="#' + item.link + '" title="' + item.title + '">' + item.title + '</a>\n');
                            if (item.time * 1000 > +new Date() - 24 * 3600 * 3 * 1000) {
                                arr.push('\t\t\t\t\t\t\t\t\t\t<span class="label label-success">New</span>\n');
                            }
                            arr.push('\t\t\t\t\t\t\t\t</h2>\n');
                            arr.push('\t\t\t\t\t\t\t\t<p>' + render.cutstr(item.content.replace(/<[^>]*>/g, ' ').replace(/\s+/g, ' '), 140) + '</p>\n');
                            arr.push('\t\t\t\t\t\t\t\t<p>\n');
                            arr.push('\t\t\t\t\t\t\t\t\t<a href="#' + item.link + '" title="Read more" rel="nofollow" class="btn btn-primary pull-right" role="button"><span class="glyphicon glyphicon-link" aria-hidden="true"></span> Read more</a>\n');
                            arr.push('\t\t\t\t\t\t\t\t\t<span class="glyphicon glyphicon-time text-muted" aria-hidden="true"></span>\n');
                            var t = new Date(item.time * 1000);
                            var y = '' + t.getFullYear();
                            var m = ('0' + (t.getMonth() + 1)).slice(-2);
                            var d = ('0' + t.getDate()).slice(-2);
                            arr.push('\t\t\t\t\t\t\t\t\t<span class="text-muted">' + (m + '/' + d + '/' + y.slice(-2)) + '</span>\n');
                            arr.push('\t\t\t\t\t\t\t\t</p>\n');
                            arr.push('\t\t\t\t\t\t\t</div>\n');
                            arr.push('\t\t\t\t\t\t</div>\n');
                            arr.push('\t\t\t\t\t</div>\n');
                            arr.push('\t\t\t\t</div>\n');
                            arr.push('\t\t\t</div>\n');
                            arr.push('\t\t</div>\n');
                        });
                    } else {
                        arr.push('\t\t<div class="row">\n');
                        arr.push('\t\t\t<div class="col-md-12">\n');
                        arr.push('\t\t\t\t<p class="text-center text-muted">' + (data.localize.no_page ? data.localize.no_page : '还没有页面') + '</p>\n');
                        arr.push('\t\t\t</div>\n');
                        arr.push('\t\t</div>\n');
                    }
                    // 分页
                    if (parseInt(data.main.count)) {
                        arr.push(render.pager(data));
                    }
                    arr.push('\t</div>\n');
                    arr.push('</div>\n');
                    return arr.join('');
                },

                // 相册
                grid: function (data) {
                    var arr = [];
                    arr.push('<div class="panel panel-default">\n');
                    arr.push('\t<div class="panel-heading">' + data.main.title + '</div>\n');
                    arr.push('\t<div class="panel-body">\n');
                    data.main.list.forEach(function (item) {
                        arr.push('\t\t<div class="col-sm-6 col-md-4">\n');
                        arr.push('\t\t\t<a class="thumbnail" href="#' + item.link + '" title="' + item.title + '">\n');
                        arr.push('\t\t\t\t<img style="width:100%;height:100px;background-color:#f1f1f1;" src="" data-src="' + (item.cover ? item.cover : '') + '" alt="' + item.title + '" title="' + item.title + '" />\n');
                        arr.push('\t\t\t\t<div class="caption">\n');
                        arr.push('\t\t\t\t\t<h2 style="margin:0;font-size:14.7px;">' + item.title + '</h2>\n');
                        arr.push('\t\t\t\t</div>\n');
                        arr.push('\t\t\t</a>\n');
                        arr.push('\t\t</div>\n');
                    });
                    // 分页
                    arr.push(render.pager(data));
                    arr.push('\t</div>\n');
                    arr.push('</div>\n');
                    return arr.join('');
                },

                // 公共底部
                footer: function (data) {
                    var arr = [];
                    arr.push('<div class="container">\n');
                    arr.push('\t<div class="row">\n');
                    arr.push('\t\t<div class="col-md-12">\n');
                    if (data.is_index) {
                        arr.push('\t\t\t<div class="panel panel-default">\n');
                        arr.push('\t\t\t\t<div class="panel-body">\n');
                        arr.push('\t\t\t\t\t<span class="text-muted">' + (data.localize.friend_link ? data.localize.friend_link : '友情链接') + ':</span>\n');
                        arr.push('\t\t\t\t\t<a href="' + data.site_url + '/' + (data.lang == 'zh-CN' ? '' : data.lang + '/') + '" title="' + data.setting.webName + '">' + data.setting.webName + '</a>\n');
                        data.footer.link.forEach(function (item) {
                            arr.push('\t\t\t\t\t<span class="text-muted">-</span> <a href="' + item.url + '" title="' + item.name + '">' + item.name + '</a>\n');
                        });
                        arr.push('\t\t\t\t</div>\n');
                        arr.push('\t\t\t</div>\n');
                    }
                    arr.push('\t\t\t<p class="text-center">' + data.setting.copyright + '</p>\n');
                    arr.push('\t\t\t<p class="text-center">\n');
                    arr.push('\t\t\t\t<a class="login" href="javascript:;" rel="nofollow" title="' + (data.localize.login ? data.localize.login : '登录') + '">' + (data.localize.login ? data.localize.login : '登录') + '</a> | <a class="register" href="javascript:;" rel="nofollow" title="' + (data.localize.register ? data.localize.register : '注册') + '">' + (data.localize.register ? data.localize.register : '注册') + '</a> | <a href="javascript:;" class="logout" rel="nofollow" title="' + (data.localize.logout ? data.localize.logout : '登出') + '">' + (data.localize.logout ? data.localize.logout : '登出') + '</a>\n');
                    arr.push('\t\t\t</p>\n');
                    arr.push('\t\t\t<p class="text-center">\n');
                    arr.push('\t\t\t\t<a href="https://beian.miit.gov.cn/" rel="nofollow" title="ICP">' + data.setting.icp + '</a>\n');
                    arr.push('\t\t\t</p>\n');
                    arr.push('\t\t</div>\n');
                    arr.push('\t</div>\n');
                    arr.push('</div>\n');
                    // 回顶与播放
                    arr.push('<div class="fixed-bottom">\n');
                    arr.push('\t<div class="play-btn' + (data.voice_read == '0' || data.article_id == '0' ? ' hidden' : '') + '" title="' + (data.localize.audio_play ? data.localize.audio_play : '语音播放') + '"><span class="glyphicon glyphicon-play" aria-hidden="true"></span></div>\n');
                    arr.push('\t<div class="back-top" style="margin-top:3px" title="' + (data.localize.back_top ? data.localize.back_top : '回到顶部') + '"><span class="glyphicon glyphicon-menu-up" aria-hidden="true"></span></div>\n');
                    arr.push('</div>\n');
                    return arr.join('');
                },

                // 首页
                index: function (data) {
                    var arr = [];
                    arr.push('<div class="container">\n');
                    arr.push('\t<div class="row">\n');
                    // 左侧列表
                    arr.push('\t\t<div class="col-md-8">\n');
                    // 轮播图
                    arr.push('\t\t\t<div class="row">\n');
                    arr.push('\t\t\t\t<div class="col-md-12">\n');
                    arr.push('\t\t\t\t\t<div class="panel panel-default">\n');
                    arr.push('\t\t\t\t\t\t<div class="panel-body">\n');
                    arr.push('\t\t\t\t\t\t\t<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">\n');
                    arr.push('\t\t\t\t\t\t\t\t<ol class="carousel-indicators">\n');
                    arr.push('\t\t\t\t\t\t\t\t\t<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>\n');
                    arr.push('\t\t\t\t\t\t\t\t\t<li data-target="#carousel-example-generic" data-slide-to="1"></li>\n');
                    arr.push('\t\t\t\t\t\t\t\t\t<li data-target="#carousel-example-generic" data-slide-to="2"></li>\n');
                    if (data.setting.slide_image_4) {
                        arr.push('\t\t\t\t\t\t\t\t\t<li data-target="#carousel-example-generic" data-slide-to="3"></li>\n');
                    }
                    if (data.setting.slide_image_5) {
                        arr.push('\t\t\t\t\t\t\t\t\t<li data-target="#carousel-example-generic" data-slide-to="4"></li>\n');
                    }
                    arr.push('\t\t\t\t\t\t\t\t</ol>\n');
                    arr.push('\t\t\t\t\t\t\t\t<div class="carousel-inner" role="listbox">\n');
                    arr.push('\t\t\t\t\t\t\t\t\t<div class="item active">\n');
                    if (data.setting.slide_image_1) {
                        arr.push('\t\t\t\t\t\t\t\t\t\t<a href="#' + data.setting.slide_url_1 + '" title="First Slide"><img width="100%" src="" data-src="' + data.setting.slide_image_1 + '" alt="First Slide" /><div class="carousel-caption"></div></a>\n');
                    } else {
                        arr.push('\t\t\t\t\t\t\t\t\t\t<a href="javascript:;" title="First Slide"><img width="100%" src="" alt="First Slide" /><div class="carousel-caption"></div></a>\n');
                    }
                    arr.push('\t\t\t\t\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t\t\t\t\t\t<div class="item">\n');
                    if (data.setting.slide_image_1) {
                        arr.push('\t\t\t\t\t\t\t\t\t\t<a href="#' + data.setting.slide_url_2 + '" title="Second Slide"><img width="100%" src="" data-src="' + data.setting.slide_image_2 + '" alt="Second Slide" /><div class="carousel-caption"></div></a>\n');
                    } else {
                        arr.push('\t\t\t\t\t\t\t\t\t\t<a href="javascript:;" title="Second Slide"><img width="100%" src="" alt="Second Slide" /><div class="carousel-caption"></div></a>\n');
                    }
                    arr.push('\t\t\t\t\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t\t\t\t\t\t<div class="item">\n');
                    if (data.setting.slide_image_1) {
                        arr.push('\t\t\t\t\t\t\t\t\t\t<a href="#' + data.setting.slide_url_3 + '" title="Third Slide"><img width="100%" src="" data-src="' + data.setting.slide_image_3 + '" alt="Third Slide" /><div class="carousel-caption"></div></a>\n');
                    } else {
                        arr.push('\t\t\t\t\t\t\t\t\t\t<a href="javascript:;" title="Third Slide"><img width="100%" src="" alt="Third Slide" /><div class="carousel-caption"></div></a>\n');
                    }
                    arr.push('\t\t\t\t\t\t\t\t\t</div>\n');
                    if (data.setting.slide_image_4) {
                        arr.push('\t\t\t\t\t\t\t\t\t<div class="item">\n');
                        arr.push('\t\t\t\t\t\t\t\t\t\t<a href="#' + data.setting.slide_url_4 + '" title="Fourth Slide"><img width="100%" src="" data-src="' + data.setting.slide_image_4 + '" alt="Fourth Slide" /><div class="carousel-caption"></div></a>\n');
                        arr.push('\t\t\t\t\t\t\t\t\t</div>\n');
                    }
                    if (data.setting.slide_image_5) {
                        arr.push('\t\t\t\t\t\t\t\t\t<div class="item">\n');
                        arr.push('\t\t\t\t\t\t\t\t\t\t<a href="#' + data.setting.slide_url_5 + '" title="Five Slide"><img width="100%" src="" data-src="' + data.setting.slide_image_5 + '" alt="Five Slide" /><div class="carousel-caption"></div></a>\n');
                        arr.push('\t\t\t\t\t\t\t\t\t</div>\n');
                    }
                    arr.push('\t\t\t\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t\t\t\t\t<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">\n');
                    arr.push('\t\t\t\t\t\t\t\t\t<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>\n');
                    arr.push('\t\t\t\t\t\t\t\t\t<span class="sr-only">Previous</span>\n');
                    arr.push('\t\t\t\t\t\t\t\t</a>\n');
                    arr.push('\t\t\t\t\t\t\t\t<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">\n');
                    arr.push('\t\t\t\t\t\t\t\t\t<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>\n');
                    arr.push('\t\t\t\t\t\t\t\t\t<span class="sr-only">Next</span>\n');
                    arr.push('\t\t\t\t\t\t\t\t</a>\n');
                    arr.push('\t\t\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t</div>\n');
                    arr.push('\t\t\t</div>\n');
                    // 左侧面板列表
                    arr.push(render.list(data));
                    arr.push('\t\t</div>\n');
                    // 右侧侧边栏
                    arr.push(render.sidebar(data));
                    arr.push('\t</div>\n');
                    arr.push('</div>\n');
                    return arr.join('');
                },

                // 分类页
                category: function (data) {
                    var arr = [];
                    // 相册列表
                    if (data.category && data.category.is_gallery == '1') {
                        arr.push(render.gallery(data));
                        return arr.join('');
                    }
                    arr.push('<div class="container">\n');
                    arr.push('\t<div class="row">\n');
                    // 左侧列表
                    arr.push('\t\t<div class="col-md-8">\n');
                    // 左侧顶部
                    arr.push('\t\t\t<div class="panel panel-default">\n');
                    arr.push('\t\t\t\t<div class="panel-body">\n');
                    // 搜索框
                    arr.push('\t\t\t\t\t<div class="row">\n');
                    arr.push('\t\t\t\t\t\t<div class="col-md-12">\n');
                    arr.push('\t\t\t\t\t\t\t<form class="input-group search-form">\n');
                    arr.push('\t\t\t\t\t\t\t\t<input type="text" name="q" value="' + data.q + '" class="form-control" placeholder="Search for..." required="required" />\n');
                    arr.push('\t\t\t\t\t\t\t\t<span class="input-group-btn">\n');
                    arr.push('\t\t\t\t\t\t\t\t\t<button class="btn btn-default" type="submit">\n');
                    arr.push('\t\t\t\t\t\t\t\t\t\t<span class="glyphicon glyphicon-search" aria-hidden="true"></span>\n');
                    arr.push('\t\t\t\t\t\t\t\t\t</button>\n');
                    arr.push('\t\t\t\t\t\t\t\t</span>\n');
                    arr.push('\t\t\t\t\t\t\t</form>\n');
                    arr.push('\t\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t\t<hr>\n');
                    // 分类描述
                    arr.push('\t\t\t\t\t<div class="row">\n');
                    arr.push('\t\t\t\t\t\t<div class="col-sm-2 col-md-2">\n');
                    arr.push('\t\t\t\t\t\t\t<img class="img-thumbnail" style="width:100%;max-height:100px;background-color:#f1f1f1;" src="' + (data.category && data.category.cover ? data.categoroy.cover : 'data:image/svg+xml,%3Csvg version=\'1.1\' xmlns=\'http://www.w3.org/2000/svg\' width=\'32\' height=\'32\' viewBox=\'0 0 32 32\'%3E%3Cpath d=\'M18.007 9.040l7.585-2.545 6.362 18.962-7.585 2.545zM0 28h8v-22h-8v22zM2 10h4v2h-4v-2zM10 28h8v-22h-8v22zM12 10h4v2h-4v-2z\'%3E%3C/path%3E%3C/svg%3E%0A') + '" alt="' + (data.category && data.category.name ? data.category.name : (data.tran.uncategoried ? data.tran.uncategoried : '未分类')) + '" title="' + (data.category && data.category.name ? data.category.name : (data.tran.uncategoried ? data.tran.uncategoried : '未分类')) + '" />\n');
                    arr.push('\t\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t\t\t<div class="col-sm-10 col-md-10">\n');
                    arr.push('\t\t\t\t\t\t\t<h1 style="margin-top: 0;">' + (data.category && data.category.name ? data.category.name : (data.tran.uncategoried ? data.tran.uncategoried : '未分类')) + ' <span class="label label-info">' + (data.main.count) + ' ' + (data.tran.articles ? data.tran.articles : '篇文章') + '</span></h1>\n');
                    arr.push('\t\t\t\t\t\t\t<p class="well well-sm">' + (data.category && data.category.description ? data.category.description : (data.tran.no_category_description ? data.tran.no_category_description : '还没有添加分类描述信息')) + '</p>\n');
                    arr.push('\t\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t</div>\n');
                    arr.push('\t\t\t</div>\n');
                    // 左侧面板列表
                    arr.push(render.list(data));
                    arr.push('\t\t</div>\n');
                    // 右侧侧栏
                    arr.push(render.sidebar(data));
                    arr.push('\t</div>\n');
                    arr.push('</div>\n');
                    return arr.join('');
                },

                // 相册页
                gallery: function (data) {
                    var arr = [];
                    arr.push('<div class="container">\n');
                    arr.push('\t<div class="row">\n');
                    // 左侧列表
                    arr.push('\t\t<div class="col-md-8">\n');
                    // 左侧面板列表
                    arr.push(render.grid(data));
                    arr.push('\t\t</div>\n');
                    // 右侧侧栏
                    arr.push(render.sidebar(data));
                    arr.push('\t</div>\n');
                    arr.push('</div>\n');
                    return arr.join('');
                },

                // 标签页
                tag: function (data) {
                    var arr = [];
                    arr.push('<div class="container">\n');
                    arr.push('\t<div class="row">\n');
                    // left list
                    arr.push('\t\t<div class="col-md-8">\n');
                    // panel left list
                    arr.push(render.list(data));
                    arr.push('\t\t</div>\n');
                    // right sidebar
                    arr.push(render.sidebar(data));
                    arr.push('\t</div>\n');
                    arr.push('</div>\n');
                    return arr.join('');
                },

                // 搜索页
                search: function (data) {
                    var arr = [];
                    arr.push('<div class="container">\n');
                    arr.push('\t<div class="row">\n');
                    // 左侧列表
                    arr.push('\t\t<div class="col-md-8">\n');
                    // 搜索框
                    arr.push('\t\t\t<div class="panel panel-default">\n');
                    arr.push('\t\t\t\t<div class="panel-body">\n');
                    arr.push('\t\t\t\t\t<div class="row">\n');
                    arr.push('\t\t\t\t\t\t<div class="col-md-12">\n');
                    arr.push('\t\t\t\t\t\t\t<form class="input-group search-form">\n');
                    arr.push('\t\t\t\t\t\t\t\t<input type="text" name="q" value="' + data.q + '" class="form-control" placeholder="Search for..." required="required" />\n');
                    arr.push('\t\t\t\t\t\t\t\t<span class="input-group-btn">\n');
                    arr.push('\t\t\t\t\t\t\t\t\t<button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></button>\n');
                    arr.push('\t\t\t\t\t\t\t\t</span>\n');
                    arr.push('\t\t\t\t\t\t\t</form>\n');
                    arr.push('\t\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t</div>\n');
                    arr.push('\t\t\t</div>\n');
                    // panel left list
                    arr.push(render.list(data));
                    arr.push('\t\t</div>\n');
                    arr.push(render.sidebar(data));
                    arr.push('\t</div>\n');
                    arr.push('</div>\n');
                    return arr.join('');
                },

                // 详情页
                detail: function (data) {
                    var arr = [];
                    arr.push('<div class="container">\n');
                    arr.push('\t<div class="row">\n');
                    // 左侧列表
                    arr.push('\t\t<div class="col-md-8">\n');
                    // 详情内容
                    arr.push('\t\t\t<div class="panel panel-default">\n');
                    arr.push('\t\t\t\t<div class="panel-body">\n');
                    arr.push('\t\t\t\t\t<h1 class="text-center" id="title">' + (data.article ? data.article.title : (data.tran.untitled ? data.tran.untitled : '无标题')) + '</h1>\n');
                    arr.push('\t\t\t\t\t<br>\n');
                    // 元信息
                    arr.push('\t\t\t\t\t<div class="panel panel-default">\n');
                    arr.push('\t\t\t\t\t\t<div class="panel-body">\n');
                    arr.push('\t\t\t\t\t\t\t<div class="pull-left">\n')
                    var t = new Date(data.article ? data.article.create_at * 1000 : 0);
                    var y = '' + t.getFullYear();
                    var m = ('0' + (t.getMonth() + 1)).slice(-2);
                    var d = ('0' + t.getDate()).slice(-2);
                    arr.push('\t\t\t\t\t\t\t\t<span class="glyphicon glyphicon-time text-muted" aria-hidden="true"></span> ' + (m + '/' + d + '/' + y.slice(-2)) + ' &nbsp;&nbsp;\n');
                    arr.push('\t\t\t\t\t\t\t\t<span class="glyphicon glyphicon-eye-open text-muted" aria-hidden="true"></span> <span class="post-views">' + (data.article ? parseInt(data.article.views) : 0) + '</span> &nbsp;&nbsp;\n');
                    arr.push('\t\t\t\t\t\t\t\t<span class="glyphicon glyphicon-folder-open text-muted" aria-hidden="true"></span> &nbsp;' + (data.category ? '<a href="#' + data.category.link + '" title="' + data.category.name + '">' + data.category.name + '</a>' : (data.tran.uncategoried ? data.tran.uncategoried : '未分类')) + ' &nbsp;&nbsp;\n');
                    arr.push('\t\t\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t\t\t\t<div class="pull-right">\n');
                    arr.push('\t\t\t\t\t\t\t\t<svg class="glyphicon" version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 32 32" fill="#777777">\n');
                    arr.push('\t\t\t\t\t\t\t\t\t<path d="M28 12c-1.1 0-2 0.9-2 2v8c0 1.1 0.9 2 2 2s2-0.9 2-2v-8c0-1.1-0.9-2-2-2zM4 12c-1.1 0-2 0.9-2 2v8c0 1.1 0.9 2 2 2s2-0.9 2-2v-8c0-1.1-0.9-2-2-2zM7 23c0 1.657 1.343 3 3 3v0 4c0 1.1 0.9 2 2 2s2-0.9 2-2v-4h4v4c0 1.1 0.9 2 2 2s2-0.9 2-2v-4c1.657 0 3-1.343 3-3v-11h-18v11z"></path>\n');
                    arr.push('\t\t\t\t\t\t\t\t\t<path d="M24.944 10c-0.304-2.746-1.844-5.119-4.051-6.551l1.001-2.001c0.247-0.494 0.047-1.095-0.447-1.342s-1.095-0.047-1.342 0.447l-1.004 2.009-0.261-0.104c-0.893-0.297-1.848-0.458-2.84-0.458s-1.947 0.161-2.84 0.458l-0.261 0.104-1.004-2.009c-0.247-0.494-0.848-0.694-1.342-0.447s-0.694 0.848-0.447 1.342l1.001 2.001c-2.207 1.433-3.747 3.805-4.051 6.551v1h17.944v-1h-0.056zM13 8c-0.552 0-1-0.448-1-1s0.447-0.999 0.998-1c0.001 0 0.002 0 0.003 0s0.001-0 0.002-0c0.551 0.001 0.998 0.448 0.998 1s-0.448 1-1 1zM19 8c-0.552 0-1-0.448-1-1s0.446-0.999 0.998-1c0 0 0.001 0 0.002 0s0.002-0 0.003-0c0.551 0.001 0.998 0.448 0.998 1s-0.448 1-1 1z"></path>\n');
                    arr.push('\t\t\t\t\t\t\t\t</svg>\n');
                    arr.push('\t\t\t\t\t\t\t\t<a href="' + data.site_url + '/static/upload/yesu.co.apk" download="yesu.co.apk" role="button" title="Android ' + (data.tran.custom ? data.tran.custom : '客户端') + '">' + (data.tran.custom ? data.tran.custom : '客户端') + '</a> &nbsp;&nbsp;\n');
                    arr.push('\t\t\t\t\t\t\t\t<svg class="glyphicon" version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 32 32" fill="#777777">\n');
                    arr.push('\t\t\t\t\t\t\t\t\t<path d="M0 2v20h32v-20h-32zM30 20h-28v-16h28v16zM21 24h-10l-1 4-2 2h16l-2-2z"></path>\n');
                    arr.push('\t\t\t\t\t\t\t\t</svg>\n');
                    arr.push('\t\t\t\t\t\t\t\t<a href="' + data.site_url + '/desktop.html" download="' + data.setting.webName + '.html" role="button" title="PC ' + (data.tran.custom ? data.tran.custom : '客户端') + '">' + (data.tran.custom ? data.tran.custom : '客户端') + '</a>\n');
                    arr.push('\t\t\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t\t</div>\n');
                    // 工具栏
                    arr.push('\t\t\t\t\t<div class="btn-toolbar" role="toolbar" aria-label="Toolbar with button groups">\n');
                    // 语音朗读
                    if (data.setting.voice_read == '1') {
                        arr.push('\t\t\t\t\t\t<div class="btn-group btn-group-lg" role="group" aria-label="First group">\n');
                        arr.push('\t\t\t\t\t\t\t<button type="button" class="btn btn-default" disabled="disabled" aria-label="Left Align">\n');
                        arr.push('\t\t\t\t\t\t\t\t<span class="glyphicon glyphicon-headphones" aria-hidden="true"></span>\n');
                        arr.push('\t\t\t\t\t\t\t</button>\n');
                        arr.push('\t\t\t\t\t\t\t<button type="button" class="btn btn-default btn-play"' + (!data.voice ? ' disabled="disabled"' : '') + ' aria-label="Left Align">\n');
                        arr.push('\t\t\t\t\t\t\t\t<span class="glyphicon glyphicon-play" aria-hidden="true"></span>\n');
                        arr.push('\t\t\t\t\t\t\t</button>\n');
                        arr.push('\t\t\t\t\t\t</div>\n');
                    } else {
                        arr.push('\t\t\t\t\t\t<div class="btn-group btn-group-lg pull-left" role="group" aria-label="First group">\n');
                        arr.push('\t\t\t\t\t\t\t<a href="' + data.site_url + '/app.html" download="H5' + data.setting.webName + '.html" role="button" title="H5 ' + (data.tran.custom ? data.tran.custom : '客户端') + '" class="btn btn-default" aria-label="Left Align">\n');
                        arr.push('\t\t\t\t\t\t\t\t<span class="glyphicon glyphicon-phone" aria-hidden="true"></span> H5 ' + (data.tran.custom ? data.tran.custom : '客户端') + '\n');
                        arr.push('\t\t\t\t\t\t\t</a>\n');
                        arr.push('\t\t\t\t\t\t</div>\n');
                    }
                    // 文字缩放
                    arr.push('\t\t\t\t\t\t<div class="btn-group btn-group-lg pull-right ignore" role="group" aria-label="Second group">\n');
                    arr.push('\t\t\t\t\t\t\t<button type="button" class="btn btn-default font-zoom" data-size="bigger" aria-label="Right Align">\n');
                    arr.push('\t\t\t\t\t\t\t\tA <sup>+</sup>\n');
                    arr.push('\t\t\t\t\t\t\t</button>\n');
                    arr.push('\t\t\t\t\t\t\t<button type="button" class="btn btn-default font-zoom" data-size="smaller" aria-label="Right Align">\n');
                    arr.push('\t\t\t\t\t\t\t\tA <sup>-</sup>\n');
                    arr.push('\t\t\t\t\t\t\t</button>\n');
                    arr.push('\t\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t\t<div id="loading"></div>\n');
                    // 内容区域
                    arr.push('\t\t\t\t\t<div class="entry-content">\n');
                    if (data.article && data.article.description) {
                        arr.push('\t\t\t\t\t\t<p class="lead">' + data.article.description + '</p>\n');
                    }
                    if (data.article) {
                        arr.push('\t\t\t\t\t\t' + data.article.content + '\n');
                    } else {
                        arr.push('\t\t\t\t\t\t' + (data.tran.no_content ? data.tran.no_content : '还没有内容信息') + '\n');
                    }
                    arr.push('\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t\t<br>\n');
                    // 分享按钮
                    arr.push('\t\t\t\t\t<div class="text-center">\n');
                    arr.push('\t\t\t\t\t\t<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 32 32"><path d="M27 22c-1.411 0-2.685 0.586-3.594 1.526l-13.469-6.734c0.041-0.258 0.063-0.522 0.063-0.791s-0.022-0.534-0.063-0.791l13.469-6.734c0.909 0.94 2.183 1.526 3.594 1.526 2.761 0 5-2.239 5-5s-2.239-5-5-5-5 2.239-5 5c0 0.269 0.022 0.534 0.063 0.791l-13.469 6.734c-0.909-0.94-2.183-1.526-3.594-1.526-2.761 0-5 2.239-5 5s2.239 5 5 5c1.411 0 2.685-0.586 3.594-1.526l13.469 6.734c-0.041 0.258-0.063 0.522-0.063 0.791 0 2.761 2.239 5 5 5s5-2.239 5-5c0-2.761-2.239-5-5-5z" fill="#777777"></path></svg>&nbsp;\n');
                    arr.push('\t\t\t\t\t\t<span id="social-share" data-initialized="true" data-image="' + data.article.cover + '">\n');
                    arr.push('\t\t\t\t\t\t\t<a href="javascript:;" rel="nofollow" title="Share weibo" class="social-share-icon icon-weibo"></a>\n');
                    arr.push('\t\t\t\t\t\t\t<a href="javascript:;" rel="nofollow" title="Share qq" class="social-share-icon icon-qq"></a>\n');
                    arr.push('\t\t\t\t\t\t\t<a href="javascript:;" rel="nofollow" title="Share wechat" class="social-share-icon icon-wechat"></a>\n');
                    arr.push('\t\t\t\t\t\t\t<a href="javascript:;" rel="nofollow" title="Share douban" class="social-share-icon icon-douban"></a>\n');
                    arr.push('\t\t\t\t\t\t\t<a href="javascript:;" rel="nofollow" title="Share qzone" class="social-share-icon icon-qzone"></a>\n');
                    arr.push('\t\t\t\t\t\t\t<a href="javascript:;" rel="nofollow" title="Share linkedin" class="social-share-icon icon-linkedin"></a>\n');
                    arr.push('\t\t\t\t\t\t\t<a href="javascript:;" rel="nofollow" title="Share facebook" class="social-share-icon icon-facebook"></a>\n');
                    arr.push('\t\t\t\t\t\t\t<a href="javascript:;" rel="nofollow" title="Share twitter" class="social-share-icon icon-twitter"></a>\n');
                    arr.push('\t\t\t\t\t\t\t<a href="javascript:;" rel="nofollow" title="Share google" class="social-share-icon icon-google"></a>\n');
                    arr.push('\t\t\t\t\t\t</span>\n');
                    arr.push('\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t\t<br>\n');
                    // 下载内容
                    arr.push('\t\t\t\t\t<div class="text-center">\n');
                    arr.push('\t\t\t\t\t\t<div class="btn-group">\n');
                    arr.push('\t\t\t\t\t\t\t<a type="button" class="btn btn-info' + (data.download ? '' : ' btn-download') + '" aria-label="Download" href="' + (data.download ? data.download : 'javascript:;') + '" title="' + (data.tran.download_content ? data.tran.download_content : '下载内容') + '"' + (data.download ? ' onclick="javascript:this.setAttribute(\'download\', \'ID' + (Array(7).join('0') + data.article.id).slice(-7) + '-' + data.article.title.split(/\s+/).join('-') + '.html\');"' : '') + '><span class="glyphicon glyphicon-download-alt" aria-label="Download"></span> ' + (data.tran.download_content ? data.tran.download_content : '下载内容') + '</a>\n');
                    arr.push('\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t\t<div class="btn-group">\n');
                    arr.push('\t\t\t\t\t\t<button type="button" class="btn btn-warning btn-favorite" aria-label="Favorite" title="' + (data.tran.favorite_article ? data.tran.favorite_article : '收藏文章') + '"><span class="glyphicon glyphicon-star-empty" aria-hidden="true"></span> ' + (data.tran.favorite_article ? data.tran.favorite_article : '收藏文章') + '</button>\n');
                    arr.push('\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t<br>\n');
                    // 版权信息
                    arr.push('\t\t\t\t<div class="well well-sm text-muted">\n');
                    arr.push('\t\t\t\t\t' + (data.tran.copyr_info ? data.tran.copyr_info : '除非特别说明，本博客均为原创，如需转载，请以链接形式标明来源出处。') + '<br>\n');
                    arr.push('\t\t\t\t\t' + (data.tran.copyr_address ? data.tran.copyr_address : '本文博客网址') + '：' + (data.article ? (location.protocol.match(/http:|https:/i) ? location.href : data.site_url + data.article.link) : (data.tran.no_address ? data.tran.no_address : '还没有网址')) + '\n');
                    arr.push('\t\t\t\t</div>\n');
                    // 点赞
                    arr.push('\t\t\t\t<button type="button" class="btn btn-success' + (data.login ? ' btn-likes' : ' login') + '">\n');
                    arr.push('\t\t\t\t\t<span class="glyphicon glyphicon-thumbs-up" aria-hidden="true"></span> ' + (data.tran.article_useful ? data.tran.article_useful : '这篇文章很有用') + '\n');
                    arr.push('\t\t\t\t</button>\n');
                    arr.push('\t\t\t\t<button type="button" class="btn btn-link text-primary" disabled="disabled">\n');
                    arr.push('\t\t\t\t\t<span class="glyphicon glyphicon-fire" aria-hidden="true"></span>\n');
                    arr.push('\t\t\t\t\t<span class="post-likes">' + (data.article ? data.article.likes : 0) + '</span> ' + (data.tran.people_likes ? data.tran.people_likes : '人觉得这篇文章很赞') + '\n');
                    arr.push('\t\t\t\t</button>\n');
                    // 上一页下一页
                    arr.push('\t\t\t\t<ul class="pager">\n');
                    arr.push('\t\t\t\t\t<li class="previous' + (data.main.prev ? '' : ' disabled="disabled"') + '">\n');
                    if (data.main.prev) {
                        arr.push('\t\t\t\t\t\t<a href="#' + data.main.prev.link + '"><span aria-hidden="true">&larr;</span> Older</a>\n');
                    } else {
                        arr.push('\t\t\t\t\t\t<span aria-hidden="true">&larr; ' + (data.tran.nothing ? data.tran.nothing : '没有了') + '</span>\n')
                    }
                    arr.push('\t\t\t\t\t</li>\n');
                    arr.push('\t\t\t\t\t<li class="next' + (data.main.next ? '' : ' disabled="disabled"') + '">\n');
                    if (data.main.next) {
                        arr.push('\t\t\t\t\t\t<a href="#' + data.main.next.link + '">Newer <span aria-hidden="true">&rarr;</span></a>\n');
                    } else {
                        arr.push('\t\t\t\t\t\t<span aria-hidden="true">' + (data.tran.nothing ? data.tran.nothing : '没有了') + ' &rarr;</span>\n');
                    }
                    arr.push('\t\t\t\t\t</li>\n');
                    arr.push('\t\t\t\t</ul>\n');
                    // 内容标签
                    if (data.main.tags.length) {
                        arr.push('\t\t\t\t<hr>\n');
                        arr.push('\t\t\t\t<span class="glyphicon glyphicon-tags text-muted" aria-hidden="true"></span> &nbsp;\n');
                        data.main.tags.forEach(function (item, i) {
                            if (i !== 0) {
                                arr.push(', ');
                            }
                            arr.push('<a href="#' + item.link + '" title="' + item.name + '">' + item.name + '</a>');
                        });
                    }
                    arr.push('\t\t\t</div>\n');
                    arr.push('\t\t</div>\n');
                    // 相关文章
                    if (data.main.related.length) {
                        arr.push('\t\t<div class="panel panel-default">\n');
                        arr.push('\t\t\t<div class="panel-heading">\n');
                        arr.push('\t\t\t\t<h3 class="panel-title">' + (data.tran.related_articles ? data.tran.related_articles : '相关文章') + '</h3>\n');
                        arr.push('\t\t\t</div>\n');
                        arr.push('\t\t\t<div class="panel-body">\n');
                        // 相册卡片
                        arr.push('\t\t\t\t<div class="row">\n');
                        data.main.related.forEach(function (item) {
                            arr.push('\t\t\t\t\t<div class="col-sm-4">\n');
                            arr.push('\t\t\t\t\t\t<div class="thumbnail">\n');
                            arr.push('\t\t\t\t\t\t\t<a href="#' + item.link + '" title="' + item.title + '">\n');
                            arr.push('\t\t\t\t\t\t\t\t<img style="width:100%;height:95px;background-color:#f1f1f1;" src="' + (item.cover ? item.cover : '') + '" alt="' + item.title + '" title="' + item.title + '" />\n');
                            arr.push('\t\t\t\t\t\t\t</a>\n');
                            arr.push('\t\t\t\t\t\t\t<div class="caption">\n');
                            arr.push('\t\t\t\t\t\t\t\t<h3 style="margin:0;font-size:14.7px;">\n');
                            arr.push('\t\t\t\t\t\t\t\t\t<a href="#' + item.link + '" title="' + item.title + '">' + item.title + '</a>\n');
                            arr.push('\t\t\t\t\t\t\t\t</h3>\n');
                            arr.push('\t\t\t\t\t\t\t</div>\n');
                            arr.push('\t\t\t\t\t\t</div>\n');
                            arr.push('\t\t\t\t\t</div>\n');
                        });
                        arr.push('\t\t\t\t</div>\n');
                        arr.push('\t\t\t</div>\n');
                        arr.push('\t\t</div>\n');
                    }
                    // 评论区域
                    arr.push('\t\t<div class="panel panel-default" id="comments">\n');
                    arr.push('\t\t\t<div class="panel-heading">\n');
                    arr.push('\t\t\t\t<h3 class="panel-title">' + (data.tran.post_comment ? data.tran.post_comment : '发表评论') + '</h3>\n');
                    arr.push('\t\t\t</div>\n');
                    arr.push('\t\t\t<div class="panel-body">\n');
                    arr.push('\t\t\t\t<div class="row">\n');
                    arr.push('\t\t\t\t\t<div class="col-md-12" id="comment-area">\n');
                    // 评论框
                    arr.push('\t\t\t\t\t\t<form id="commentForm" class="commentForm" style="position: relative">\n');
                    arr.push('\t\t\t\t\t\t\t<div class="form-group">\n');
                    if (data.article && data.article.can_comment == '0') {
                        arr.push('\t\t\t\t\t\t\t\t<textarea class="form-control" rows="3" name="comment" class="form-control" id="comment" placeholder="' + (data.tran.comment_content ? data.tran.comment_content : '评论内容') + '..."' + (data.setting.can_comment == '1' && !data.login ? ' disabled' : '') + ' required></textarea>\n');
                    }
                    if (data.article && data.article.can_comment == '0' && data.setting.can_comment == '1' && !data.login) {
                        arr.push('\t\t\t\t\t\t\t\t<p style="position: absolute;top: 30%;margin-top: -1rem;left: 50%;margin-left: -8rem;">' + (data.tran.please ? data.tran.please : '请') + ' [<a class="login" href="javascript:;" rel="nofollow" title="' + (data.tran.login ? data.tran.login : '登录') + '">' + (data.tran.login ? data.tran.login : '登录') + '</a>] ' + (data.tran.after_comment ? data.tran.after_comment : '后评论') + '</p>\n');
                    }
                    arr.push('\t\t\t\t\t\t\t</div>\n');
                    if (data.article && data.article.can_comment == '0') {
                        arr.push('\t\t\t\t\t\t\t<div class="form-group" style="position: relative;text-align: right;">\n');
                        arr.push('\t\t\t\t\t\t\t\t<input type="hidden" name="post_id" value="' + data.article.id + '" />\n');
                        arr.push('\t\t\t\t\t\t\t\t<input type="hidden" name="pid" value="0">\n');
                        if (data.login && data.login.auth_ids.indexOf('88') !== -1) {
                            arr.push('\t\t\t\t\t\t\t\t<input type="hidden" name="can_delete" value="1">\n');
                        } else {
                            arr.push('\t\t\t\t\t\t\t\t<input type="hidden" name="can_delete" value="0">\n');
                        }
                        arr.push('\t\t\t\t\t\t\t\t<input type="hidden" name="token" value="' + render.token + '">\n');
                        arr.push('\t\t\t\t\t\t\t\t<input type="hidden" name="anti_spam" value="' + data.anti_spam_val + '">\n');
                        arr.push('\t\t\t\t\t\t\t\t<button type="submit" class="btn btn-primary">\n');
                        arr.push('\t\t\t\t\t\t\t\t\t<span class="glyphicon glyphicon-send" aria-hidden="true"></span> ' + (data.tran.post_comment ? data.tran.post_comment : '发表评论') + '\n');
                        arr.push('\t\t\t\t\t\t\t\t</button>\n');
                        arr.push('\t\t\t\t\t\t\t\t<span class="tips" style="position: absolute;left: 0;top: .5rem;"></span>\n');
                        arr.push('\t\t\t\t\t\t\t</div>\n');
                    }
                    arr.push('\t\t\t\t\t\t</form>\n');
                    // 评论列表
                    if (data.main.comments.length) {
                        data.main.comments.forEach(function (item) {
                            arr.push('\t\t\t\t\t\t\t<div class="panel panel-default" id="comment-' + item.id + '">\n');
                            arr.push('\t\t\t\t\t\t\t\t<div class="panel-body">\n');
                            // 媒体对象
                            arr.push('\t\t\t\t\t\t\t\t\t<div class="media">\n');
                            arr.push('\t\t\t\t\t\t\t\t\t\t<div class="media-left">\n');
                            arr.push('\t\t\t\t\t\t\t\t\t\t\t<img class="media-object img-circle avatar" style="width: 64px;height: 64px;background-color: #f1f1f1;" src="' + (item.cover ? item.cover : '') + '" alt="' + (item.nickname ? item.nickname : '') + '" title="' + (item.nickname ? item.nickname : '') + '" />\n');
                            arr.push('\t\t\t\t\t\t\t\t\t\t</div>\n');
                            arr.push('\t\t\t\t\t\t\t\t\t\t<div class="media-body">\n');
                            arr.push('\t\t\t\t\t\t\t\t\t\t\t<h4 class="media-heading"><strong>' + (item.nickname ? item.nickname : 'anonymous') + '</strong> <cite>' + (data.tran.say ? data.tran.say : '说道') + '：</cite></h4>\n');
                            // 评论内容
                            arr.push('\t\t\t\t\t\t\t\t\t\t\t' + item.comment + (data.login && data.login.auth_ids.indexOf('88') !== -1 ? ' （<a href="javascript:;" class="delete-comment text-danger" data-id="' + item.id + '" title="' + (data.tran.delete ? data.tran.delete : '删除') + '">' + (data.tran.delete ? data.tran.delete : '删除') + '</a>）' : '') + '\n');
                            arr.push('\t\t\t\t\t\t\t\t\t\t\t<div class="clearfix" style="margin: 10px 0;">\n');
                            arr.push('\t\t\t\t\t\t\t\t\t\t\t\t<button type="button" data-id="' + item.id + '" class="pull-right btn btn-success btn-reply btn-sm media-right">\n');
                            arr.push('\t\t\t\t\t\t\t\t\t\t\t\t\t<span class="glyphicon glyphicon-share-alt" aria-hidden="true"></span> ' + (data.tran.reply ? data.tran.reply : '回复') + '\n');
                            arr.push('\t\t\t\t\t\t\t\t\t\t\t\t</button>\n');
                            arr.push('\t\t\t\t\t\t\t\t\t\t\t</div>\n');
                            // 回复列表
                            item.replies.forEach(function (reply, i) {
                                arr.push('\t\t\t\t\t\t\t\t\t\t\t<div class="media' + (i > 4 ? ' hidden' : '') + '" id="comment-' + reply.id + '">\n');
                                arr.push('\t\t\t\t\t\t\t\t\t\t\t\t<hr style="margin-top: 10px;" />\n');
                                arr.push('\t\t\t\t\t\t\t\t\t\t\t\t<div class="media-left">\n');
                                arr.push('\t\t\t\t\t\t\t\t\t\t\t\t\t<img class="media-object img-circle avatar" style="width: 64px;height: 64px;background-color: #f1f1f1;" src="' + (reply.avatar ? reply.avatar : '') + '" alt="' + reply.nickname + '" title="' + reply.nickname + '" />\n');
                                arr.push('\t\t\t\t\t\t\t\t\t\t\t\t</div>\n');
                                arr.push('\t\t\t\t\t\t\t\t\t\t\t\t<div class="media-body">\n');
                                arr.push('\t\t\t\t\t\t\t\t\t\t\t\t\t<h4 class="media-heading">' + reply.nickname + ' ' + (data.tran.reply ? data.tran.reply : '回复') + '：</h4>\n');
                                arr.push('\t\t\t\t\t\t\t\t\t\t\t\t\t' + reply.comment + (data.login && data.login.auth_ids.indexOf('88') !== -1 ? ' （<a href="javascript:;" class="delete-comment text-danger" data-id="' + reply.id + '" title="' + (data.tran.delete ? data.tran.delete : '删除') + '">' + (data.tran.delete ? data.tran.delete : '删除') + '</a>）' : '') + '\n');
                                arr.push('\t\t\t\t\t\t\t\t\t\t\t\t</div>\n');
                                arr.push('\t\t\t\t\t\t\t\t\t\t\t</div>\n');
                                // 回复分页
                                if (i == item.replies.length - 1 && i > 4) {
                                    arr.push('\t\t\t\t\t\t\t\t\t\t\t<nav aria-label="Page navigation">\n');
                                    arr.push('\t\t\t\t\t\t\t\t\t\t\t\t<hr />\n');
                                    arr.push('\t\t\t\t\t\t\t\t\t\t\t\t<ul class="pager pager-reply" data-index="0">\n');
                                    arr.push('\t\t\t\t\t\t\t\t\t\t\t\t\t<li class="disabled" data-type="prev"><a href="javascript:;" title="Previous">Previous</a></li>\n');
                                    arr.push('\t\t\t\t\t\t\t\t\t\t\t\t\t<li data-type="next"><a href="javascript:;" title="Next">Next</a></li>\n');
                                    arr.push('\t\t\t\t\t\t\t\t\t\t\t\t\t<li data-type="all"><a href="javascript:;" title="All">All</a></li>\n');
                                    arr.push('\t\t\t\t\t\t\t\t\t\t\t\t</ul>\n');
                                    arr.push('\t\t\t\t\t\t\t\t\t\t\t</nav>\n');
                                }
                            });
                            arr.push('\t\t\t\t\t\t\t\t\t\t</div>\n');
                            arr.push('\t\t\t\t\t\t\t\t\t</div>\n');
                            arr.push('\t\t\t\t\t\t\t\t</div>\n');
                            arr.push('\t\t\t\t\t\t\t</div>\n');
                        });
                    } else {
                        arr.push('\t\t\t\t\t\t\t<p class="text-center text-muted no-comment">' + (data.tran.no_comment ? data.tran.no_comment : '还没有评论') + '</p>\n');
                    }
                    arr.push('\t\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t\t</div>\n');
                    // 评论分页
                    if (data.article && data.article.can_comment) {
                        arr.push(render.pager(data));
                    }
                    arr.push('\t\t\t\t</div>\n');
                    arr.push('\t\t\t</div>\n');
                    arr.push('\t\t</div>\n');
                    arr.push(render.sidebar(data));
                    arr.push('\t</div>\n');
                    arr.push('</div>\n');
                    return arr.join('');
                },

                // 独立页面
                page: function (data) {
                    var arr = [];
                    if (data.page && data.page.is_full == '1') {
                        arr.push(render.page_full(data));
                        return arr.join('');
                    }
                    // 文章收藏或点赞列表
                    if (data.page && data.page.slug.match(/^page-/) && render[data.page.slug.replace('-', '_')]) {
                        arr.push(render[data.page.slug.replace('-', '_')](data));
                        return arr.join('');
                    }
                    arr.push('<div class="container">\n');
                    arr.push('\t<div class="row">\n');
                    // 左侧列表
                    arr.push('\t\t<div class="col-md-8">\n');
                    if (data.main.list.length) {
                        arr.push(render.list_page(data));
                    } else {
                        arr.push('\t\t\t<div class="panel panel-default">\n');
                        arr.push('\t\t\t\t<div class="panel-body">\n');
                        // 页面内容
                        arr.push('\t\t\t\t\t<div class="row">\n');
                        arr.push('\t\t\t\t\t\t<div class="col-md-12 entry-content">\n');
                        if (data.page) {
                            arr.push('\t\t\t\t\t\t\t' + data.page.content + '\n');
                        } else {
                            arr.push('\t\t\t\t\t\t\t<p>' + (data.tran.no_page ? data.tran.no_page : '还没有页面') + '</p>\n');
                        }
                        arr.push('\t\t\t\t\t\t</div>\n');
                        arr.push('\t\t\t\t\t</div>\n');
                        arr.push('\t\t\t\t</div>\n');
                        arr.push('\t\t\t</div>\n');
                    }
                    arr.push('\t\t</div>\n');
                    arr.push(render.sidebar(data));
                    arr.push('\t</div>\n');
                    arr.push('</div>\n');
                    return arr.join('');
                },

                // 宽屏页
                page_full: function (data) {
                    var arr = [];
                    arr.push('<div class="container">\n');
                    if (data.main.list.length) {
                        arr.push(render.list_page(data));
                    } else {
                        arr.push('\t<div class="row">\n');
                        // 宽屏内容
                        arr.push('\t\t<div class="col-md-12 entry-content">\n');
                        if (data.page) {
                            arr.push('\t\t\t' + data.page.content + '\n');
                        } else {
                            arr.push('\t\t\t<p>' + (data.tran.no_page ? data.tran.no_page : '还没有页面') + '</p>\n');
                        }
                        arr.push('\t\t</div>\n');
                        arr.push('\t</div>\n');
                    }
                    arr.push('</div>\n');
                    return arr.join('');
                },

                // 收藏页面
                page_favorites: function (data) {
                    var arr = [];
                    arr.push('<div class="container">\n');
                    arr.push('\t<div class="row">\n');
                    // 左侧列表
                    arr.push('\t\t<div class="col-md-8">\n');
                    // 左侧顶部
                    arr.push('\t\t\t<div class="panel panel-default">\n');
                    arr.push('\t\t\t\t<div class="panel-body">\n');
                    // 页面描述
                    arr.push('\t\t\t\t\t<div class="row">\n');
                    arr.push('\t\t\t\t\t\t<div class="col-sm-2 col-md-2">\n');
                    arr.push('\t\t\t\t\t\t\t<img class="img-thumbnail" style="width:100%;max-height:100px;background-color:#f1f1f1;" src="' + (data.page && data.page.cover ? data.page.cover : 'data:image/svg+xml,%3Csvg version=\'1.1\' xmlns=\'http://www.w3.org/2000/svg\' width=\'32\' height=\'32\' viewBox=\'0 0 32 32\'%3E%3Cpath d=\'M32 12.408l-11.056-1.607-4.944-10.018-4.944 10.018-11.056 1.607 8 7.798-1.889 11.011 9.889-5.199 9.889 5.199-1.889-11.011 8-7.798z\'%3E%3C/path%3E%3C/svg%3E%0A') + '" alt="' + (data.page ? data.page.title : (data.tran.unnamed ? data.tran.unnamed : '未命名')) + '" title="' + (data.page ? data.page.title : (data.tran.unnamed ? data.tran.unnamed : '未命名')) + '" />\n');
                    arr.push('\t\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t\t\t<div class="col-sm-10 col-md-10">\n');
                    arr.push('\t\t\t\t\t\t\t<h1 style="margin-top: 0;">' + (data.page ? data.page.title : (data.tran.unnamed ? data.tran.unnamed : '未命名')) + ' <span class="label label-info"><i id="page-counts">0</i> ' + (data.tran.articles ? data.tran.articles : '篇文章') + '</span></h1>\n');
                    arr.push('\t\t\t\t\t\t\t<p class="well well-sm">' + (data.page && data.page.description ? data.page.description : (data.tran.no_page_description ? data.tran.no_page_description : '还没有页面描述信息')) + '</p>\n');
                    arr.push('\t\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t</div>\n');
                    arr.push('\t\t\t</div>\n');
                    // 面板左侧列表
                    arr.push('\t\t\t<div class="panel panel-default">\n');
                    arr.push('\t\t\t\t<div class="panel-body" id="page-lists" data-slug="page-favorites"></div>\n');
                    arr.push('\t\t\t</div>\n');
                    arr.push('\t\t</div>\n');
                    // 右侧侧栏
                    arr.push(render.sidebar(data));
                    arr.push('\t</div>\n');
                    arr.push('</div>\n');
                    return arr.join('');
                },

                // 点赞页面
                page_likes: function (data) {
                    var arr = [];
                    arr.push('<div class="container">\n');
                    arr.push('\t<div class="row">\n');
                    // 左侧列表
                    arr.push('\t\t<div class="col-md-8">\n');
                    // 左侧顶部
                    arr.push('\t\t\t<div class="panel panel-default">\n');
                    arr.push('\t\t\t\t<div class="panel-body">\n');
                    // 页面描述
                    arr.push('\t\t\t\t\t<div class="row">\n');
                    arr.push('\t\t\t\t\t\t<div class="col-sm-2 col-md-2">\n');
                    arr.push('\t\t\t\t\t\t\t<img class="img-thumbnail" style="width:100%;max-height:100px;background-color:#f1f1f1;" src="' + (data.page && data.page.cover ? data.page.cover : 'data:image/svg+xml,%3Csvg version=\'1.1\' xmlns=\'http://www.w3.org/2000/svg\' width=\'32\' height=\'32\' viewBox=\'0 0 32 32\'%3E%3Cpath d=\'M29 18c2.281 0 1 6-1 6 1 0 0 5-2 5 0 2-2 3-4 3-8.448 0-5.477-2.114-14-3v-16c7.529-2.258 15-7.92 15-13 1.656 0 6 2 0 12 0 0 5 0 6 0 3 0 2 6 0 6zM6 13v16h2v1h-4c-1.1 0-2-1.35-2-3v-12c0-1.65 0.9-3 2-3h4v1h-2z\'%3E%3C/path%3E%3C/svg%3E%0A') + '" alt="' + (data.page ? data.page.title : (data.tran.unnamed ? data.tran.unnamed : '未命名')) + '" title="' + (data.page ? data.page.title : (data.tran.unnamed ? data.tran.unnamed : '未命名')) + '" />\n');
                    arr.push('\t\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t\t\t<div class="col-sm-10 col-md-10">\n');
                    arr.push('\t\t\t\t\t\t\t<h1 style="margin-top: 0;">' + (data.page ? data.page.title : (data.tran.unnamed ? data.tran.unnamed : '未命名')) + ' <span class="label label-info"><i id="page-counts">0</i> ' + (data.tran.articles ? data.tran.articles : '篇文章') + '</span></h1>\n');
                    arr.push('\t\t\t\t\t\t\t<p class="well well-sm">' + (data.page && data.page.description ? data.page.description : (data.tran.no_page_description ? data.tran.no_page_description : '还没有页面描述信息')) + '</p>\n');
                    arr.push('\t\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t\t</div>\n');
                    arr.push('\t\t\t\t</div>\n');
                    arr.push('\t\t\t</div>\n');
                    // 面板左侧列表
                    arr.push('\t\t\t<div class="panel panel-default">\n');
                    arr.push('\t\t\t\t<div class="panel-body" id="page-lists" data-slug="page-likes"></div>\n');
                    arr.push('\t\t\t</div>\n');
                    arr.push('\t\t</div>\n');
                    // 右侧侧栏
                    arr.push(render.sidebar(data));
                    arr.push('\t</div>\n');
                    arr.push('</div>\n');
                    return arr.join('');
                },

                // 分页
                pager: function (data) {
                    var arr = [];
                    arr.push('<div class="row">\n');
                    arr.push('\t<div class="col-md-12 text-center">\n');
                    arr.push('\t\t<nav aria-label="Page navigation">\n');
                    arr.push('\t\t\t<ul class="pagination pagination-lg">\n');
                    data.main.pager.forEach(function (item, i) {
                        if (i == 0) {
                            arr.push('\t\t\t\t<li' + (data.p == item.p ? ' class="disabled"' : '') + '><a href="' + (data.p == item.p ? 'javascript:;' : '#' + item.link) + '" aria-label="Previous" title="' + item.title + '"><span aria-hidden="true">&laquo;</span></a></li>\n');
                        }
                        if (i > 0 && i < data.main.pager.length - 1) {
                            arr.push('\t\t\t\t<li' + (data.p == item.p ? ' class="active"' : '') + '><a href="' + (data.p == item.p ? 'javascript:;' : '#' + item.link) + '" title="' + item.title + '">' + item.p + '</a></li>\n');
                        }
                        if (i == data.main.pager.length - 1) {
                            arr.push('\t\t\t\t<li' + (data.p == item.p ? ' class="disabled"' : '') + '><a href="' + (data.p == item.p ? 'javascript:;' : '#' + item.link) + '" aria-label="Next" title="' + item.title + '"><span aria-hidden="true">&raquo;</span></a></li>\n')
                        }
                    });
                    arr.push('\t\t\t</ul>\n');
                    arr.push('\t\t</nav>\n');
                    arr.push('\t</div>\n');
                    arr.push('</div>\n');
                    return arr.join('');
                },

                // Ajax请求前
                beforeSend: function () {
                    // 重置变量
                    render.stop();
                    render.stopped = true;
                    render.audio = new Audio();
                    render.audioArray = [];
                    render.textArray = [];
                    render.nodes = [];
                    render.speechInstance = null;
                    render.offLine = false;
                    render.ttsApi = '';
                    render.playErrors = 0;
                    render.playErrorTimer = null;
                    render.timer = null;
                    render.affixTop = 0;

                    // 解绑事件
                    $(window).off('click', render.click);
                    $(window).off('submit', render.submit);
                    $(window).off('scroll', render.scroll);
                    render.loader();
                },

                // Ajax请求错误
                error: function (XMLHttpRequest, statusText) {
                    // 解绑事件
                    $(window).off('click', render.click);
                    $(window).off('submit', render.submit);
                    $(window).off('scroll', render.scroll);
                    if (XMLHttpRequest.responseText && XMLHttpRequest.responseText.match(/404 Not found/i)) {
                        return $('#app').html(render.err404());
                    }
                    render.loader('Error', statusText ? statusText : 'Status code: ' + XMLHttpRequest.status);
                    setTimeout(function() {
                        $('#loader').remove();
                    }, 1500);
                },

                // 加载器
                loader: function (title, msg) {
                    var arr = [];
                    $('#loader').remove();
                    arr.push('<div id="loader">\n');
                    arr.push('\t<div class="inner">\n');
                    arr.push('\t\t<h3>' + (title ? title : 'Loading...') + '</h3>\n');
                    arr.push('\t\t<div id="loading">' + (msg ? msg : '<i class="icon-loading"></i>') + '</div>\n');
                    arr.push('\t</div>\n');
                    arr.push('</div>\n');
                    $('#app').append(arr.join(''));
                },

                // 字符串截取
                cutstr: function (str, n, suffix) {
                    var len = 0;
                    var arr = [];
                    for (var i in str) {
                        arr.push(str[i]);
                        len += str[i].length;
                        if (str[i].charCodeAt(0).toString(16).length == 4) {
                            len += 1;
                        }
                        if (len > n) {
                            arr.pop();
                            arr.push(suffix || '...');
                            break;
                        }
                    }
                    return arr.join('');
                },

                // 图片懒加载
                lazyLoad: function() {
                    var wHeight = $(window).innerHeight();
                    $('img').each(function (i, elem) {
                        if ($('html, body').scrollTop() + wHeight > $(elem).offset().top) {
                            if ($(elem).attr('src').match(/^data:image/) && $(elem).data('src') && $(elem).data('src').match(/\./)) {
                                $(elem).prop('src', $(elem).data('src'));
                            }
                        }
                    });
                },

                // 模态弹出框
                alertBox: function(msg, title) {
                    var arr = [];
                    arr.push('<div class="modal fade bs-modal-alert" tabindex="-1" role="dialog">\n')
                    arr.push('\t<div class="modal-dialog modal-sm" role="document">\n');
                    arr.push('\t\t<div class="modal-content">\n');
                    arr.push('\t\t\t<div class="modal-header">\n');
                    arr.push('\t\t\t\t<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>\n');
                    arr.push('\t\t\t\t<h4 class="modal-title">' + (title ? title : (render.data.localize.info ? render.data.localize.info : '信息')) + '</h4>\n');
                    arr.push('\t\t\t</div>\n');
                    arr.push('\t\t\t<div class="modal-body">' + msg + '</div>\n');
                    arr.push('\t\t\t<div class="modal-footer">\n');
                    arr.push('\t\t\t\t<button type="button" class="btn btn-default" data-dismiss="modal">' + (render.data.localize.sure ? render.data.localize.sure : '确定') + '</button>\n');
                    arr.push('\t\t\t</div>\n');
                    arr.push('\t\t</div>\n');
                    arr.push('\t</div>\n');
                    arr.push('</div>\n');
                    $('.bs-modal-alert').modal('hide');
                    $('.bs-modal-alert').remove();
                    $('body').append(arr.join(''));
                    $('.bs-modal-alert').modal('show');
                },

                // 初始化执行
                load: function() {
                    // 多语切换
                    if (render.lang && render.langs.indexOf(render.lang) !== -1 && render.data.lang != render.lang) {
                        location.hash = '#' + (render.lang == 'zh-CN' ? '' : '/' + render.lang) + render.path.replace(new RegExp('^/' + render.data.lang + '/'), '/');
                    }

                    // 图片懒加载
                    render.lazyLoad();
                    if ($("#panel-affix").length) {
                        render.affixTop = $("#panel-affix").offset().top;
                        render.docHeight = $(document).height();
                    }
                    
                    // 数据美化
                    render.sanitize();

                    // 绑定事件
                    $(window).on('click', render.click);
                    $(window).on('submit', render.submit);
                    $(window).on('scroll', render.scroll);
                },

                // 点击事件
                click: function(e) {
                    // 模态框
                    var loginArr = [];
                    var registerArr = [];
                    loginArr.push('<div class="modal fade bs-modal-login" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">\n');
                    loginArr.push('\t<div class="modal-dialog modal-sm" role="document">\n');
                    loginArr.push('\t\t<div class="modal-content">\n');
                    loginArr.push('\t\t\t<div class="modal-header">\n');
                    loginArr.push('\t\t\t\t<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>\n');
                    loginArr.push('\t\t\t\t<h4 class="modal-title">' + (render.data.localize.login ? render.data.localize.login : '登录') + ' <small><a class="register" href="javascript:;" rel="nofollow" title="' + (render.data.localize.switch_register ? render.data.localize.switch_register : '切换注册') + '">' + (render.data.localize.switch_register ? render.data.localize.switch_register : '切换注册') + '</a></small></h4>\n');
                    loginArr.push('\t\t\t</div>\n');
                    loginArr.push('\t\t\t<div class="modal-body">\n');
                    loginArr.push('\t\t\t\t<form id="loginForm" class="loginForm" style="height: 200px;">\n');
                    loginArr.push('\t\t\t\t\t<div class="form-group">\n');
                    loginArr.push('\t\t\t\t\t\t<label for="inputUsername">' + (render.data.localize.username ? render.data.localize.username : '用户名') + '</label>\n');
                    loginArr.push('\t\t\t\t\t\t<input type="text" class="form-control" name="username" value="anonymous" id="inputUsername" placeholder="' + (render.data.localize.input_username ? render.data.localize.input_username : '请输入用户名') + '" />\n');
                    loginArr.push('\t\t\t\t\t</div>\n');
                    loginArr.push('\t\t\t\t\t<div class="form-group">\n');
                    loginArr.push('\t\t\t\t\t\t<label for="inputPasswrod">' + (render.data.localize.password ? render.data.localize.password : '密码') + '</label>\n');
                    loginArr.push('\t\t\t\t\t\t<input type="password" class="form-control" name="password" value="123456" id="inputPasswrod" placeholder="' + (render.data.localize.input_password ? render.data.localize.input_password : '请输入密码') + '" />\n');
                    loginArr.push('\t\t\t\t\t</div>\n');
                    loginArr.push('\t\t\t\t\t<div class="form-group" style="position: relative;">\n');
                    loginArr.push('\t\t\t\t\t\t<input type="hidden" name="token" value="' + render.token + '" />\n');
                    loginArr.push('\t\t\t\t\t\t<button type="submit" class="btn btn-primary pull-right">' + (render.data.localize.login ? render.data.localize.login : '登录') + '</button>\n');
                    loginArr.push('\t\t\t\t\t\t<span class="tips"></span>\n');
                    loginArr.push('\t\t\t\t\t</div>\n');
                    loginArr.push('\t\t\t\t</form>\n');
                    loginArr.push('\t\t\t</div>\n');
                    loginArr.push('\t\t</div>\n');
                    loginArr.push('\t</div>\n');
                    loginArr.push('</div>\n');
                    registerArr.push('<div class="modal fade bs-modal-register" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">\n');
                    registerArr.push('\t<div class="modal-dialog modal-sm" role="document">\n');
                    registerArr.push('\t\t<div class="modal-content">\n');
                    registerArr.push('\t\t\t<div class="modal-header">\n');
                    registerArr.push('\t\t\t\t<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>\n');
                    registerArr.push('\t\t\t\t<h4 class="modal-title">' + (render.data.localize.register ? render.data.localize.register : '注册') + ' <small><a class="login" href="javascript:;" rel="nofollow" title="' + (render.data.localize.switch_login ? render.data.localize.switch_login : '切换登录') + '">' + (render.data.localize.switch_login ? render.data.localize.switch_login : '切换登录') + '</a></small></h4>\n');
                    registerArr.push('\t\t\t</div>\n');
                    registerArr.push('\t\t\t<div class="modal-body">\n');
                    registerArr.push('\t\t\t\t<form id="registerForm" class="registerForm" style="height: 420px;">\n');
                    registerArr.push('\t\t\t\t\t<div class="form-group">\n');
                    registerArr.push('\t\t\t\t\t\t<label for="inputRegUsername">' + (render.data.localize.username ? render.data.localize.username : '用户名') + '</label>\n');
                    registerArr.push('\t\t\t\t\t\t<input type="text" class="form-control" name="username" value="" id="inputRegUsername" placeholder="' + (render.data.localize.input_username ? render.data.localize.input_username : '请输入用户名') + '" />\n');
                    registerArr.push('\t\t\t\t\t</div>\n');
                    registerArr.push('\t\t\t\t\t<div class="form-group">\n');
                    registerArr.push('\t\t\t\t\t\t<label for="inputRegPasswrod">' + (render.data.localize.password ? render.data.localize.password : '密码') + '</label>\n');
                    registerArr.push('\t\t\t\t\t\t<input type="password" class="form-control" name="password" value="" id="inputRegPasswrod" placeholder="' + (render.data.localize.input_password ? render.data.localize.input_password : '请输入密码') + '" />\n');
                    registerArr.push('\t\t\t\t\t</div>\n');
                    registerArr.push('\t\t\t\t\t<div class="form-group">\n');
                    registerArr.push('\t\t\t\t\t\t<label for="inputRegRepeatPassword">' + (render.data.localize.repeat_password ? render.data.localize.repeat_password : '重复密码') + '</label>\n');
                    registerArr.push('\t\t\t\t\t\t<input type="password" class="form-control" name="repeat_password" value="" id="inputRegRepeatPassword" placeholder="' + (render.data.localize.input_repeat_password ? render.data.localize.input_repeat_password : '请重输入密码') + '" />\n');
                    registerArr.push('\t\t\t\t\t</div>\n');
                    registerArr.push('\t\t\t\t\t<div class="form-group">\n');
                    registerArr.push('\t\t\t\t\t\t<label for="inputRegNickname">' + (render.data.localize.nickname ? render.data.localize.nickname : '昵称') + '</label>\n');
                    registerArr.push('\t\t\t\t\t\t<input type="text" class="form-control" name="nickname" value="" id="inputRegNickname" placeholder="' + (render.data.localize.optional ? render.data.localize.optional : '可选') + '" />\n');
                    registerArr.push('\t\t\t\t\t</div>\n');
                    registerArr.push('\t\t\t\t\t<div class="form-group">\n');
                    registerArr.push('\t\t\t\t\t\t<label for="inputRegPhone">' + (render.data.localize.phone ? render.data.localize.phone : '手机') + '</label>\n');
                    registerArr.push('\t\t\t\t\t\t<input type="text" class="form-control" name="phone" value="" id="inputRegPhone" placeholder="' + (render.data.localize.optional ? render.data.localize.optional : '可选') + '" />\n');
                    registerArr.push('\t\t\t\t\t</div>\n');
                    registerArr.push('\t\t\t\t\t<div class="form-group" style="position: relative;">\n');
                    registerArr.push('\t\t\t\t\t\t<input type="hidden" name="token" value="' + render.token + '" />\n');
                    registerArr.push('\t\t\t\t\t\t<button type="submit" class="btn btn-primary pull-right">' + (render.data.localize.register ? render.data.localize.register : '注册') + '</button>\n');
                    registerArr.push('\t\t\t\t\t\t<span class="tips"></span>\n');
                    registerArr.push('\t\t\t\t\t</div>\n');
                    registerArr.push('\t\t\t\t</form>\n');
                    registerArr.push('\t\t\t</div>\n');
                    registerArr.push('\t\t</div>\n');
                    registerArr.push('\t</div>\n');
                    registerArr.push('</div>\n');

                    // 多语切换
                    if ($(e.target).hasClass('multilang')) {
                        var slug = $(e.target).data('slug');
                        var lang = render.lang;
                        render.lang = slug;
                        render.setItem('multiLang', slug);
                        $('html').attr('lang', slug);
                        location.hash = '#' + (render.lang == 'zh-CN' ? '' : '/' + render.lang) + render.path.replace(new RegExp('^/' + lang + '/'), '/');
                        return false;
                    }

                    // 登录框
                    if ($(e.target).hasClass('login')) {
                        $.post(render.data.site_url + (render.data.lang == 'zh-CN' ? '' : '/' + render.data.lang) + '/api/ajax/islogin.html', { token: render.token }, function (res) {
                            if (res.code) return render.alertBox(res.msg);
                            $('.bs-modal-login').remove();
                            $('body').append(loginArr.join(''));
                            $('.bs-modal-register').modal('hide');
                            $('.bs-modal-login').modal('show');
                        }, 'json');
                        return false;
                    }

                    // 注册框
                    if ($(e.target).hasClass('register')) {
                        $.post(render.data.site_url + (render.data.lang == 'zh-CN' ? '' : '/' + render.data.lang) + '/api/ajax/islogin.html', { token: render.token }, function (res) {
                            if (res.code) return render.alertBox(res.msg);
                            $('.bs-modal-register').remove();
                            $('body').append(registerArr.join(''));
                            $('.bs-modal-login').modal('hide');
                            $('.bs-modal-register').modal('show');
                        }, 'json');
                        return false;
                    }

                    // 登出
                    if ($(e.target).hasClass('logout')) {
                        $.post(render.data.site_url + (render.data.lang == 'zh-CN' ? '' : '/' + render.data.lang) + '/api/ajax/logout.html', { token: render.token }, function (res) {
                            if (res.code) return render.alertBox(res.msg);
                            if (undefined !== res.token) render.removeItem('webToken');
                            render.alertBox(res.msg);
                            setTimeout(function () {
                                if (self.frameElement && self.frameElement.tagName == 'IFRAME') {
                                    parent.window.location.reload();
                                } else {
                                    window.location.reload();
                                }
                            }, 1000);
                        }, 'json');
                        return false;
                    }

                    // 下载内容
                    if ($(e.target).hasClass('btn-download')) {
                        $.ajax({
                            type: 'POST',
                            url: render.data.site_url + (render.data.lang == 'zh-CN' ? '' : '/' + render.data.lang) + '/api/ajax/download.html',
                            data: {
                                post_id: render.data.article_id,
                            },
                            dataType: 'json',
                            cache: false,
                            beforeSend: function () {
                                $(e.target).attr('disabled', 'disabled').removeClass('btn-download');
                                $(e.target).parent().next('.btn-group').next('.loading').remove();
                                $(e.target).parent().next('.btn-group').after('<div class="text-muted loading" style="margin-top:10px"><span class="glyphicon glyphicon-refresh" style="animation: turn-around 1.5s linear infinite;" aria-hidden="true"></span> ' + (render.data.localize.merging ? render.data.localize.merging : '正在合成，请稍后') + '...</div>');
                            },
                            success: function (res) {
                                if (res.code) {
                                    $(e.target).removeAttr('disabled').addClass('btn-download');
                                    $(e.target).parent().next('.btn-group').next('.loading').removeClass('text-muted').addClass('text-danger').html('<span class="glyphicon glyphicon-remove"></span> ' + res.msg);
                                } else {
                                    $(e.target).removeAttr('disabled').removeClass('btn-download').attr('href', res.link).attr('download', 'ID' + (Array(7).join('0') + render.data.article_id).slice(-7) + '-' + render.data.lang + '-' + res.msg + '.html');
                                    $(e.target).parent().next('.btn-group').next('.loading').removeClass('text-muted').addClass('text-success').html('<span class="glyphicon glyphicon-ok"></span> ' + (render.data.localize.merge_success ? render.data.localize.merge_success : '合成成功！再次点击按钮下载。'));
                                }
                                setTimeout(function () {
                                    $(e.target).parent().next('.btn-group').next('.loading').remove();
                                }, 5000);
                            },
                            error: function (response) {
                                $(e.target).removeAttr('disabled').addClass('btn-download');
                                $(e.target).parent().next('.btn-group').next('.loading').removeClass('text-muted').addClass('text-warning').html('<span class="glyphicon glyphicon-alert"></span> Error! ' + response.statusText + ' ' + response.status);
                                setTimeout(function () {
                                    $(e.target).parent().next('.btn-group').next('.loading').remove();
                                }, 3000);
                            }
                        });
                        return false;
                    }

                    // 收藏文章
                    if ($(e.target).hasClass('btn-favorite')) {
                        var store = [];
                        try {
                            store = JSON.parse(render.getItem(render.data.langs && render.data.langs.length ? 'multiPostFavorites' : 'postFavorites') || '[]');
                        } catch (e) {
                            render.removeItem(render.data.langs && render.data.langs.length ? 'multiPostFavorites' : 'postFavorites');
                            store = [];
                        }
                        // var obj = store.find(function (item) {
                        //     return item.id == render.data.article_id;
                        // });
                        // 兼容IE10
                        var obj = null;
                        for (var i = 0; i < store.length; i++) {
                            if (store[i].id == render.data.article_id) {
                                obj = store[i];
                            }
                        }
                        if (!obj && $(e.target).hasClass('btn-warning') && window.localStorage) {
                            $(e.target).removeClass('btn-warning').attr('title', (render.data.localize.favorite_cancel ? render.data.localize.favorite_cancel : '取消收藏')).html('<span class="glyphicon glyphicon-star" aria-hidden="true"></span> ' + (render.data.localize.favorite_success ? render.data.localize.favorite_success : '收藏成功'));
                            store.unshift({ id: render.data.article_id, timestamp: +new Date(), lang: render.data.lang });
                        } else {
                            $(e.target).addClass('btn-warning').attr('title', (render.data.localize.favorite_article ? render.data.localize.favorite_article : '收藏文章')).html('<span class="glyphicon glyphicon-star-empty" aria-hidden="true"></span> ' + (render.data.localize.favorite_article ? render.data.localize.favorite_article : '收藏文章'));
                            // var index = store.findIndex(function (item) {
                            //     return item.id == render.data.article_id;
                            // });
                            // store.splice(index, 1);
                            // 兼容IE10
                            var newArr = [];
                            for (var i = 0; i < store.length; i++) {
                                if (store[i].id == render.data.article_id)
                                    continue;
                                newArr.push(store[i]);
                            }
                            store = newArr;
                        }
                        render.setItem(render.data.langs && render.data.langs.length ? 'multiPostFavorites' : 'postFavorites', JSON.stringify(store));
                        $('.panel-pages .list-group a[data-slug="page-favorites"]').find('.badge').text(store.length);
                        return false;
                    }

                    // 点赞
                    if ($(e.target).hasClass('btn-likes')) {
                        var likes = parseInt(render.data.article_likes);
                        var store = [];
                        try {
                            store = JSON.parse(render.getItem(render.data.langs && render.data.langs.length ? 'multiPostLikes' : 'postLikes') || '[]');
                        } catch (e) {
                            render.removeItem(render.data.langs && render.data.langs.length ? 'multiPostLikes' : 'postLikes');
                            store = [];
                        }
                        if ($(e.target).hasClass('disabled') || $(e.target).hasClass('btn-disabled') || !window.localStorage)
                            return false;
                        $(e.target).addClass('disabled').addClass('btn-disabled');
                        store.unshift({ id: render.data.article_id, likes: likes + 1, timestamp: +new Date(), lang: render.data.lang });
                        render.setItem(render.data.langs && render.data.langs.length ? 'multiPostLikes' : 'postLikes', JSON.stringify(store));
                        $('.post-likes').html(likes + 1);
                        $.post(render.data.site_url + (render.data.lang == 'zh-CN' ? '' : '/' + render.data.lang) + '/api/ajax/likes.html', { id: render.data.article_id, likes: likes }, 'json');
                        $('.panel-pages .list-group a[data-slug="page-likes"]').find('.badge').text(store.length);
                        return false;
                    }

                    // 语音朗读
                    if ($(e.target).hasClass('btn-play') || $(e.target).parent().hasClass('btn-play')) {
                        return render.play();
                    }
                    if ($(e.target).hasClass('btn-pause') || $(e.target).parent().hasClass('btn-pause')) {
                        return render.pause();
                    }
                    if ($(e.target).hasClass('btn-stop') || $(e.target).parent().hasClass('btn-stop')) {
                        return render.stop();
                    }

                    // 更改字体大小
                    if ($(e.target).hasClass('font-zoom') || $(e.target).parent().hasClass('font-zoom')) {
                        var thisEle = $('.entry-content').css('font-size');
                        var textFontSize = parseFloat(thisEle, 10);
                        var unit = thisEle.slice(-2); //
                        var cName = $(e.target).data('size') || $(e.target).parent().data('size');
                        if (cName == 'bigger') {
                            if (textFontSize <= 24) {
                                textFontSize += 2;
                            }
                        } else if (cName == 'smaller') {
                            if (textFontSize >= 14) {
                                textFontSize -= 2;
                            }
                        }
                        $('.entry-content').css('font-size', textFontSize + unit);
                        return false;
                    }

                    // 回复评论
                    if ($(e.target).hasClass('btn-reply') || $(e.target).parent().hasClass('btn-reply')) {
                        $('#comment-area .btn-cancel-reply').removeClass('btn-cancel-reply').addClass('btn-reply').removeClass('btn-danger').addClass('btn-success').html('<span class="glyphicon glyphicon-share-alt" aria-hidden="true"></span> ' + (render.data.localize.reply ? render.data.localize.reply : '回复'));
                        ($(e.target).hasClass('btn-reply') ? $(e.target) : $(e.target).parent()).removeClass('btn-reply').addClass('btn-cancel-reply').removeClass('btn-success').addClass('btn-danger').html(render.data.localize.cancel_reply ? render.data.localize.cancel_reply : '取消回复').parent().after($('#commentForm'));
                        $(e.target).removeClass('btn-reply').addClass('btn-cancel-reply').removeClass('btn-success').addClass('btn-danger').html(render.data.localize.cancel_reply ? render.data.localize.cancel_reply : '取消回复').parent().after($('#commentForm'));
                        $('#commentForm button[type="submit"]').html('@ ' + (render.data.localize.reply_comment ? render.data.localize.reply_comment : '回复评论'));
                        $('#commentForm').find('input[name="pid"]').val(($(e.target).hasClass('btn-reply') ? $(e.target) : $(e.target).parent()).data('id'));
                        $('#commentForm').find('input[name="pid"]').val($(e.target).data('id'));
                        return false;
                    }

                    // 取消回复
                    if ($(e.target).hasClass('btn-cancel-reply') || $(e.target).parent().hasClass('btn-cancel-reply')) {
                        $('#comment-area').prepend($('#commentForm')).find('.btn-cancel-reply').removeClass('btn-cancel-reply').addClass('btn-reply').removeClass('btn-danger').addClass('btn-success').html('<span class="glyphicon glyphicon-share-alt" aria-hidden="true"></span> ' + (render.data.localize.reply ? render.data.localize.reply : '回复'));
                        $('#commentForm button[type="submit"]').html('<span class="glyphicon glyphicon-send" aria-hidden="true"></span> ' + (render.data.localize.send_comment ? render.data.localize.send_comment : '发表评论'));
                        $('#commentForm').find('input[name="pid"]').val(0);
                        return false;
                    }

                    // 删除评论
                    if ($(e.target).hasClass('delete-comment')) {
                        if ($(e.target).parent().find('#commentForm').length) return false;
                        var comment_id = $(e.target).data('id');
                        $.post(render.data.site_url + (render.data.lang == 'zh-CN' ? '' : '/' + render.data.lang) + '/api/ajax/delete_comment.html', { comment_id: comment_id }, function (res) {
                            if (res.code) return render.alertBox(res.msg);
                            var item = $('#comment-area #comment-' + comment_id);
                            var num = item.parent('.media-body').find('.media').length - 1;
                            if (num > 5) {
                                if (!item.parent('.media-body').find('.pager').length) {
                                    var str = '<nav aria-label="Page navigation">\n';
                                    str += '<hr />\n';
                                    str += '<ul class="pager pager-reply" data-index="0">\n';
                                    str += '<li class="disabled" data-type="prev"><a href="javascript:;" title="Previous">Previous</a></li>\n';
                                    str += '<li data-type="next"><a href="javascript:;" title="Next">Next</a></li>\n';
                                    str += '<li data-type="all"><a href="javascript:;" title="All">All</a></li>\n';
                                    str += '</ul>\n';
                                    str += '</nav>\n';
                                    item.parent('.media-body').append(str);
                                }
                            } else {
                                item.parent('.media-body').find('.pager').parent().remove();
                                item.parent('.media-body').find('.media').removeClass('hidden');
                            }
                            item.remove();
                            render.alertBox(res.msg);
                            !$('#comment-area>.panel').length && $('<p class="text-center text-muted no-comment">' + (render.data.localize.no_comment ? render.data.localize.no_comment : '还没有评论') + '</p>').appendTo('#comment-area');
                        }, 'json');
                        return false;
                    }

                    // 回复评论分页
                    if ($(e.target).parent().parent().hasClass('pager-reply')) {
                        var type = $(e.target).parent().data('type');
                        var index = parseInt($(e.target).parent().parent().data('index'));
                        var total = $(e.target).parent().parent().parent().parent().children('.media').length;
                        if ($(e.target).parent().hasClass('disabled')) return false;
                        if (type === 'all') {
                            $(e.target).parent().parent().children('li').addClass('disabled');
                            $(e.target).parent().parent().parent().parent().children('.media').removeClass('hidden');
                            $(e.target).parent().parent().parent().remove();
                            return false;
                        }
                        if (type === 'prev') {
                            index -= 5;
                            if (index <= 0) index = 0;
                        }
                        if (type === 'next') {
                            index += 5;
                            if (index >= total) index -= 5;
                        }
                        $(e.target).parent().parent().data('index', index);
                        if (index === 0) {
                            $(e.target).parent().parent().children('li[data-type="prev"]').addClass('disabled');
                        } else {
                            $(e.target).parent().parent().children('li[data-type="prev"]').removeClass('disabled');
                        }
                        if (index + 5 >= total) {
                            $(e.target).parent().parent().children('li[data-type="next"]').addClass('disabled');
                        } else {
                            $(e.target).parent().parent().children('li[data-type="next"]').removeClass('disabled');
                        }
                        $(e.target).parent().parent().parent().parent().children('.media').each(function (i, elem) {
                            if (i < index || i >= index + 5) {
                                $(elem).addClass('hidden');
                            } else {
                                $(elem).removeClass('hidden');
                            }
                        });
                        return false;
                    }


                    // 侧栏分页
                    if ($(e.target).parent().parent().hasClass('pager-list')) {
                        var type = $(e.target).parent().data('type');
                        var index = parseInt($(e.target).parent().parent().data('index'));
                        var total = $(e.target).parent().parent().parent().parent().children('a.list-group-item').length;
                        if ($(e.target).parent().hasClass('disabled')) return false;
                        if (type === 'all') {
                            $(e.target).parent().parent().children('li').addClass('disabled');
                            $(e.target).parent().parent().parent().parent().children('a.list-group-item').removeClass('hidden');
                            $(e.target).parent().parent().parent().remove();
                            return false;
                        }
                        if (type === 'prev') {
                            index -= 10;
                            if (index <= 0) index = 0;
                        }
                        if (type === 'next') {
                            index += 10;
                            if (index >= total) index -= 10;
                        }
                        $(e.target).parent().parent().data('index', index);
                        if (index === 0) {
                            $(e.target).parent().parent().children('li[data-type="prev"]').addClass('disabled');
                        } else {
                            $(e.target).parent().parent().children('li[data-type="prev"]').removeClass('disabled');
                        }
                        if (index + 10 >= total) {
                            $(e.target).parent().parent().children('li[data-type="next"]').addClass('disabled');
                        } else {
                            $(e.target).parent().parent().children('li[data-type="next"]').removeClass('disabled');
                        }
                        $(e.target).parent().parent().parent().parent().children('a.list-group-item').each(function (i, elem) {
                            if (i < index || i >= index + 10) {
                                $(elem).addClass('hidden');
                            } else {
                                $(elem).removeClass('hidden');
                            }
                        });
                        return false;
                    }

                    // 回顶与播放
                    if ($(e.target).hasClass('play-btn') || $(e.target).parent().hasClass('play-btn') || $(e.target).hasClass('resume-btn') || $(e.target).parent().hasClass('resume-btn')) {
                        if ($('.btn-group .btn-resume').length) {
                            $('.btn-group .btn-resume').click();
                        } else {
                            $('.btn-group .btn-play').click();
                        }
                        return false;
                    }

                    // 模块跟随
                    if ($(e.target).hasClass('pause-btn') || $(e.target).parent().hasClass('pause-btn')) {
                        $('.btn-group .btn-pause').click();
                        return false;
                    }
                    if ($(e.target).hasClass('back-top') || $(e.target).parent().hasClass('back-top')) {
                        $('html, body').stop().animate({
                            scrollTop: 0
                        });
                        return false;
                    }
                },

                // 提交事件
                submit: function(e) {
                    e.preventDefault();
                    // 搜索框
                    if ($(e.target).hasClass('search-form')) {
                        var q = $(e.target).find('input[name="q"]').val().trim();
                        if (!q.length) return false;
                        location.hash = '#/' + (render.lang.match(/^zh-/) ? '' : render.lang + '/') + 'search.html?q=' + q;
                        return false;
                    }

                    // 登录
                    if ($(e.target).hasClass('loginForm')) {
                        $('#loginForm .tips').html('<span class="glyphicon glyphicon-refresh" style="animation: turn-around 1.5s linear infinite;" aria-hidden="true"></span> ' + (render.data.localize.logining ? render.data.localize.logining : '登录中') + '...');
                        $.post(render.data.site_url + (render.data.lang == 'zh-CN' ? '' : '/' + render.data.lang) + '/api/ajax/login.html', $('#loginForm').serialize(), function (res) {
                            if (res.code) return $('#loginForm .tips').html('<span class="glyphicon glyphicon-remove" aria-hidden="true"></span> ' + res.msg);
                            $('#loginForm .tips').html('<span class="glyphicon glyphicon-ok" aria-hidden="true"></span> ' + res.msg + '，' + (render.data.localize.redirecting ? render.data.localize.redirecting : '跳转中') + '...');
                            if (undefined !== res.token) render.setItem('webToken', res.token);
                            setTimeout(function () {
                                if (self.frameElement && self.frameElement.tagName == 'IFRAME') {
                                    parent.window.location.reload();
                                } else {
                                    window.location.reload();
                                }
                            }, 1000);
                        }, 'json');
                        return false;
                    }

                    // 注册
                    if ($(e.target).hasClass('registerForm')) {
                        $('#registerForm .tips').html('<span class="glyphicon glyphicon-refresh" style="animation: turn-around 1.5s linear infinite;" aria-hidden="true"></span> ' + (render.data.localize.registering ? render.data.localize.registering : '注册中') + '...');
                        $.post(render.data.site_url + (render.data.lang == 'zh-CN' ? '' : '/' + render.data.lang) + '/api/ajax/register.html', $('#registerForm').serialize(), function (res) {
                            if (res.code) return $('#registerForm .tips').html('<span class="glyphicon glyphicon-remove" aria-hidden="true"></span> ' + res.msg);
                            $('#registerForm .tips').html('<span class="glyphicon glyphicon-ok" aria-hidden="true"></span> ' + res.msg + '，' + (render.data.localize.redirecting ? render.data.localize.redirecting : '跳转中') + '...');
                            if (undefined !== res.token) render.setItem('webToken', res.token);
                            setTimeout(function () {
                                if (self.frameElement && self.frameElement.tagName == 'IFRAME') {
                                    parent.window.location.reload();
                                } else {
                                    window.location.reload();
                                }
                            }, 1000);
                        }, 'json');
                        return false;
                    }

                    // 提交评论
                    if ($(e.target).hasClass('commentForm')) {
                        var type = $('#comment-area .btn-cancel-reply').length;
                        $('#commentForm .tips').html('<span class="glyphicon glyphicon-refresh" style="animation: turn-around 1.5s linear infinite;" aria-hidden="true"></span> ' + (render.data.localize.submiting ? render.data.localize.submiting : '提交中') + '...');
                        $('#commentForm button[type="submit"]').attr('disabled', true);
                        $.ajax({
                            url: render.data.site_url + (render.data.lang == 'zh-CN' ? '' : '/' + render.data.lang) + '/api/ajax/comment.html',
                            type: 'POST',
                            dataType: 'json',
                            data: $('#commentForm').serialize(),
                            success: function (res) {
                                if (res.code) {
                                    $('#commentForm .tips').html('<span class="glyphicon glyphicon-remove" aria-hidden="true"></span> ' + res.msg);
                                    setTimeout(function () {
                                        $('#commentForm button[type="submit"]').attr('disabled', false);
                                        $('#commentForm .tips').html('');
                                    }, 1000);
                                    return false;
                                }
                                $('#commentForm .tips').html('<span class="glyphicon glyphicon-ok" aria-hidden="true"></span> ' + res.msg);
                                var say = type ? res.data.nickname + ' ' + (render.data.localize.reply ? render.data.localize.reply : '回复') + '：' : '<strong>' + res.data.nickname + '</strong> <cite>' + (render.data.localize.say ? render.data.localize.say : '说道') + '：</cite>';
                                html = type ? '' : '<div class="panel panel-default" id="comment-' + res.data.id + '"><div class="panel-body">';
                                html += '<div class="media" id="comment-' + res.data.id + '">';
                                html += type ? '<hr style="margin-top: 10px;">' : '';
                                html += '<div class="media-left">';
                                html += '<img class="media-object img-circle avatar" style="width: 64px;height: 64px;background-color: #f1f1f1;" src="' + (res.data.avatar ? res.data.avatar : render.generateAvatar(res.data.nickname)) + '" alt="' + res.data.nickname + '">';
                                html += '</div>';
                                html += '<div class="media-body">';
                                html += '<h4 class="media-heading">' + say + '</h4>';
                                html += res.data.comment + (res.data.status != '0' ? ' [<span class="text-success">' + (render.data.localize.pending ? render.data.localize.pending : '审核中') + '</span>]' : '');
                                html += $('#commentForm input[name="can_delete"]').val() == '1' ? '（<a href="javascript:;" class="delete-comment text-danger" data-id="' + res.data.id + '" title="' + (render.data.localize.delete ? render.data.localize.delete : '删除') + '">' + (render.data.localize.delete ? render.data.localize.delete : '删除') + '</a>）' : '';
                                html += type ? '' : '<div class="clearfix" style="margin: 10px 0;"><button type="button" data-id="' + res.data.id + '" class="pull-right btn btn-success btn-sm media-right btn-reply"><span class="glyphicon glyphicon-share-alt" aria-hidden="true"></span> ' + (render.data.localize.reply ? render.data.localize.reply : '回复') + '</button></div>';
                                html += '</div>';
                                html += '</div>';
                                html += type ? '' : '</div></div>';
                                $('#commentForm').after(html);
                                $('#commentForm #comment').val(null);
                                if (type) {
                                    var obj = $('#commentForm').parent('.media-body');
                                    var num = $('#commentForm').parent('.media-body').find('.media').length - 1;
                                    if (num > 4) {
                                        obj.find('.media').eq(5).addClass('hidden');
                                        if (!obj.find('.pager').length) {
                                            var str = '<nav aria-label="Page navigation">\n';
                                            str += '<hr />\n';
                                            str += '<ul class="pager pager-reply" data-index="0">\n';
                                            str += '<li class="disabled" data-type="prev"><a href="javascript:;">Previous</a></li>\n';
                                            str += '<li data-type="next"><a href="javascript:;">Next</a></li>\n';
                                            str += '<li data-type="all"><a href="javascript:;">All</a></li>\n';
                                            str += '</ul>\n';
                                            str += '</nav>\n';
                                            obj.append(str);
                                        }
                                    } else {
                                        obj.find('.pager').parent().remove();
                                    }
                                }
                                $('#comment-area>.panel').length && $('#comment-area>.no-comment').remove();
                                setTimeout(function () {
                                    $('#commentForm .tips').html('');
                                    $('#commentForm button[type="submit"]').attr('disabled', false);
                                    $('#comment-area .btn-cancel-reply').trigger('click');
                                }, 1000);
                            },
                            error: function (XMLHttpRequest, textStatus) {
                                $('#commentForm .tips').html(textStatus + ': ' + XMLHttpRequest.status);
                            }
                        });
                        return false;
                    }
                },

                // 滚动事件
                scroll: function(e) {
                    // 节流
                    if (render.timer) return false;
                    render.timer = setTimeout(function() {
                        // 图片懒加载
                        render.lazyLoad();

                        // 模块跟随
                        if ($(window).scrollTop() > render.affixTop) {
                            var newPosition = ($(window).scrollTop() - render.affixTop) + 35;
                            var maxPosition = render.docHeight - ($("#panel-affix").height() + render.affixTop + 135);
                            $("#panel-affix").css('margin-top', newPosition > maxPosition ? maxPosition : newPosition);
                        } else {
                            $("#panel-affix").css('margin-top', 0);
                        };

                        // 回顶与播放
                        if ($(window).scrollTop() > 300) {
                            $('body .fixed-bottom').css('display', 'block');
                        } else {
                            $('body .fixed-bottom').css('display', 'none');
                        }
                        render.timer = null;
                    }, 300);
                },

                // 语音朗读
                play: function() {
                    $('.fixed-bottom .play-btn').removeClass('play-btn').addClass('pause-btn').html('<span class="glyphicon glyphicon-pause" aria-hidden="true"></span>');
                    $('.btn-group .btn-play').next('.btn-stop').remove();
                    $('.btn-group .btn-play').after('<button type="button" class="btn btn-default btn-stop" aria-label="Left Align"><span class="glyphicon glyphicon-stop" aria-hidden="true"></span></button>');
                    $('.btn-group .btn-play').removeClass('btn-play').addClass('btn-pause').html('<span class="glyphicon glyphicon-pause" aria-hidden="true"></span>');
                    if (render.stopped) {
                        if (render.nodes.length < 1) {
                            return false;
                        }
                        $('#loading').html('<span class="icon-loading"></span> ' + (render.data.localize.waiting ? render.data.localize.waiting : '请稍后') + ' ...');
                        var icon = new Image();
                        icon.src = 'https://translate.google.com/favicon.ico?t=' + new Date().getTime();
                        var timer = setTimeout(function () {
                            icon.onerror = icon.onload = null;
                            render.youdao_dictvoice();
                        }, 3000);
                        icon.onerror = function () {
                            clearTimeout(timer);
                            timer = null;
                            render.youdao_dictvoice();
                        }
                        icon.onload = function () {
                            clearTimeout(timer);
                            timer = null;
                            render.google_translate_tts();
                        }
                    } else {
                        if (!render.offLine) {
                            render.audio.play();
                        } else {
                            window.speechSynthesis.resume();
                        }
                    }
                    return false;
                },
                pause: function() {
                    $('.fixed-bottom .pause-btn').removeClass('pause-btn').addClass('play-btn').html('<span class="glyphicon glyphicon-play" aria-hidden="true"></span>');
                    $('.btn-group .btn-pause').removeClass('btn-pause').addClass('btn-play').html('<span class="glyphicon glyphicon-play" aria-hidden="true"></span>');
                    if (!render.offLine) {
                        render.audio.pause();
                    } else {
                        if (window.speechSynthesis.speaking) {
                            window.speechSynthesis.pause();
                        }
                    }
                    return false;
                },
                stop: function() {
                    $('.fixed-bottom .pause-btn').removeClass('pause-btn').addClass('play-btn').html('<span class="glyphicon glyphicon-play" aria-hidden="true"></span>');
                    $('.btn-group .btn-stop').prev('.btn').removeClass('btn-pause').addClass('btn-play').html('<span class="glyphicon glyphicon-play" aria-hidden="true"></span>');
                    $('.btn-group .btn-stop').remove();
                    if (!render.offLine) {
                        render.audio.pause();
                        render.audio.removeEventListener('ended', render.playEndedHandler);
                        render.audio.removeEventListener('error', render.playEndedHandler);
                        render.audioArray = [];
                    } else {
                        window.speechSynthesis.cancel();
                        render.speechInstance && render.speechInstance.removeEventListener('end', render.playEndedHandler);
                    }
                    render.stopped = true;
                    render.textArray = [];
                    for (var i = 0; i < render.nodes.length; i++) {
                        if (render.nodes[i].node.nodeType === 1) {
                            $(render.nodes[i].node).removeClass('tts');
                        }
                    }
                    return false;
                },
                google_translate_tts: function() {
                    render.offLine = false;
                    render.ttsApi = 'https://translate.google.com/translate_tts?client=webapp&ie=UTF-8&oe=UTF-8&tl=' + (render.data.voice ? render.data.voice : render.data.lang) + '&q=';
                    render.doPlay();
                },
                youdao_dictvoice: function() {
                    var icon = new Image();
                    icon.src = 'https://dict.youdao.com/favicon.ico?t=' + new Date().getTime();
                    var timer = setTimeout(function () {
                        icon.onerror = icon.onload = null;
                        if (render.offLine) {
                            render.doPlay();
                        } else {
                            render.stop();
                            $('#loading').html('<div class="text-warning"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> ' + (render.data.localize.voice_read_error ? render.data.localize.voice_read_error : '朗读错误，请联网后再试') + ' ...</div>');
                        }
                    }, 3000);
                    icon.onerror = function () {
                        clearTimeout(timer);
                        timer = null;
                        if (render.offLine) {
                            render.doPlay();
                        } else {
                            render.stop();
                            $('#loading').html('<div class="text-warning"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> ' + (render.data.localize.voice_read_error ? render.data.localize.voice_read_error : '朗读错误，请联网后再试') + ' ...</div>');
                        }
                    }
                    icon.onload = function () {
                        clearTimeout(timer);
                        timer = null;
                        if (['ar', 'de', 'ru', 'fr', 'ko', 'nl', 'pt', 'ja', 'th', 'es', 'en', 'it', 'vi', 'id'].indexOf(render.data.lang) !== -1 || render.data.lang.match(/^zh-/)) {
                            render.offLine = false;
                            render.ttsApi = 'https://dict.youdao.com/dictvoice?le=' + (render.data.lang.match(/^zh-/) ? 'zh-CHS' : render.data.lang) + '&product=aibox&audio=';
                            render.doPlay();
                        } else {
                            $('#loading').html('<div class="text-warning"><span class="glyphicon glyphicon-alert"></span> ' + (render.data.localize.voice_not_support ? render.data.localize.voice_not_support : '语音不支持，需科学上网使用谷歌接口。') + '</div>');
                            $('.btn-group .btn-play').attr('disabled', true);
                        }
                    }
                },
                doPlay: function() {
                    var num = 200;
                    for (var i = 0; i < render.nodes.length; i++) {
                        var arrs = $(render.nodes[i].node).text().trim().split(/(\r\n|\r|\n)/g);
                        for (var j = 0; j < arrs.length; j++) {
                            var aAudioText = arrs[j].trim();
                            if (aAudioText && !render.offLine) {
                                while (aAudioText.length >= num) {
                                    var arr = [];
                                    for (var k in aAudioText) {
                                        arr.push(aAudioText[k]);
                                        if (arr.join('').length >= num) {
                                            arr.pop();
                                            break;
                                        }
                                    }
                                    var pos = arr.join('').length;
                                    render.textArray.push({ text: aAudioText.slice(0, pos), index: render.nodes[i].index });
                                    aAudioText = aAudioText.slice(pos);
                                }
                            }
                            aAudioText && render.textArray.push({ text: aAudioText, index: render.nodes[i].index });
                        }
                    }
                    if (render.textArray.length < 1) {
                        return false;
                    }
                    if (!render.offLine) {
                        for (var i = 0; i < render.textArray.length; i++) {
                            var address = render.ttsApi + encodeURIComponent(render.textArray[i].text);
                            if (render.ttsApi.match(/\/\/[\w]+\.google/)) {
                                address += '&tk=' + render.getTk(render.textArray[i].text);
                            }
                            render.audioArray.unshift(address);
                        }
                        render.audio.preload = true;
                        render.audio.controls = true;
                        render.audio.src = render.audioArray.pop();
                        render.audio.addEventListener('ended', render.playEndedHandler);
                        render.audio.addEventListener('error', render.playEndedHandler);
                        render.audio.loop = false;
                        render.audio.play();
                    }
                    render.stopped = false;
                    var reader = render.textArray.shift();
                    if (render.offLine) {
                        render.speechInstance = new SpeechSynthesisUtterance();
                        window.speechSynthesis.cancel();
                        render.speechInstance.lang = render.offLine;
                        render.speechInstance.text = reader.text;
                        window.speechSynthesis.speak(render.speechInstance);
                        render.speechInstance.addEventListener('end', render.playEndedHandler);
                    }
                    for (var i = 0; i < render.nodes.length; i++) {
                        if (reader.index == render.nodes[i].index) {
                            if (render.nodes[i].node.nodeType === 3) {
                                var wrapper = document.createElement('span');
                                render.nodes[i].node.parentNode.insertBefore(wrapper, render.nodes[i].node);
                                render.nodes[i].node.parentNode.removeChild(render.nodes[i].node);
                                wrapper.appendChild(render.nodes[i].node);
                                render.nodes[i].node = wrapper;
                            }
                            $(render.nodes[i].node).addClass('tts');
                        } else {
                            if (render.nodes[i].node.nodeType === 1) {
                                $(render.nodes[i].node).removeClass('tts');
                            }
                        }
                    }
                    $('#loading').html('');
                },
                playEndedHandler: function() {
                    render.playErrors = 0;
                    if (render.textArray.length > 0) {
                        if (!render.offLine) {
                            render.audio.src = render.audioArray.pop();
                            render.audio.play();
                        }
                        var reader = render.textArray.shift();
                        if (render.offLine) {
                            render.speechInstance.text = reader.text;
                            window.speechSynthesis.speak(render.speechInstance);
                        }
                        var elem = null;
                        for (var i = 0; i < render.nodes.length; i++) {
                            if (reader.index == render.nodes[i].index) {
                                if (render.nodes[i].node.nodeType === 3) {
                                    var wrapper = document.createElement('span');
                                    render.nodes[i].node.parentNode.insertBefore(wrapper, render.nodes[i].node);
                                    render.nodes[i].node.parentNode.removeChild(render.nodes[i].node);
                                    wrapper.appendChild(render.nodes[i].node);
                                    render.nodes[i].node = wrapper;
                                }
                                elem = render.nodes[i].node;
                                $(render.nodes[i].node).addClass('tts');
                            } else {
                                if (render.nodes[i].node.nodeType === 1) {
                                    $(render.nodes[i].node).removeClass('tts');
                                }
                            }
                        }
                        var clientHeight = $(window).height();
                        var scrollTop = $(window).scrollTop();
                        var pos = $(elem).offset().top;
                        var topH = $(elem).height();
                        if (pos > clientHeight + scrollTop - topH) {
                            $('html, body').stop().animate({
                                scrollTop: pos - 10
                            });
                        }
                    } else {
                        render.stop();
                        setTimeout(function () {
                            $('html, body').stop().animate({
                                scrollTop: 0
                            });
                        }, 1000);
                    }
                },
                playErrorHandler: function() {
                    render.playErrorTimer && clearTimeout(render.playErrorTimer);
                    render.playErrorTimer = setTimeout(function () {
                        if (render.playErrors % 10 < 9) {
                            render.playErrors++;
                            render.audio.src = render.audio.src.split('&t=')[0] + '&t=' + new Date().getTime();
                            render.audio.play();
                        } else {
                            clearTimeout(render.playErrorTimer);
                            render.playErrorTimer = null;
                            render.playErrors = 0;
                            render.stop();
                            $('#loading').html('<div class="text-warning"><span class="glyphicon glyphicon-alert"></span> Error! Audio error code: ' + render.audio.error.code + '</div>');
                        }
                    }, 3000 + Math.ceil(Math.random() * 2000));
                },

                // 字母图像
                generateAvatar: function(username) {
                    var canvas = document.createElement('canvas');
                    var context = canvas.getContext('2d');
                    // 设置画布尺寸
                    canvas.width = 200;
                    canvas.height = 200;
                    // 绘制背景
                    context.fillStyle = '#f4f4f4';
                    context.fillRect(0, 0, canvas.width, canvas.height);
                    // 绘制头像形状
                    context.beginPath();
                    context.arc(canvas.width / 2, canvas.height / 2, 80, 0, Math.PI * 2);
                    context.closePath();
                    context.clip();
                    // 绘制用户名首字母
                    context.fillStyle = '#555555';
                    context.font = '100px Arial';
                    context.textAlign = 'center';
                    context.textBaseline = 'middle';
                    context.fillText(username.charAt(0).toUpperCase(), canvas.width / 2, canvas.height / 2);
                    // 将生成的图像转为 base64 编码
                    var base64Image = canvas.toDataURL();
                    return base64Image;
                },

                // 谷歌tk算法
                getTk: function(a) {
                    var tkk = '406398.2087938574', e = tkk.split('.'), h = Number(e[0]) || 0, g = [], d = 0, i, j;
                    for (var f = 0; f < a.length; f++) {
                        var c = a.charCodeAt(f);
                        128 > c ? g[d++] = c : (2048 > c ? g[d++] = c >> 6 | 192 : (55296 == (c & 64512) && f + 1 < a.length && 56320 == (a.charCodeAt(f + 1) & 64512) ? (c = 65536 + ((c & 1023) << 10) + (a.charCodeAt(++f) & 1023), g[d++] = c >> 18 | 240, g[d++] = c >> 12 & 63 | 128) : g[d++] = c >> 12 | 224, g[d++] = c >> 6 & 63 | 128), g[d++] = c & 63 | 128)
                    }
                    a = h;
                    for (var d = 0; d < g.length; d++) {
                        a += g[d];
                        i = '+-a^+6';
                        for (var k = 0; k < i.length - 2; k += 3) {
                            j = i.charAt(k + 2);
                            j = 'a' <= j ? j.charCodeAt(0) - 87 : Number(j);
                            j = '+' == i.charAt(k + 1) ? a >>> j : a << j;
                            a = '+' == i.charAt(k) ? a + j & 4294967295 : a ^ j;
                        }
                    }
                    i = '+-3^+b+-f';
                    for (var k = 0; k < i.length - 2; k += 3) {
                        j = i.charAt(k + 2);
                        j = 'a' <= j ? j.charCodeAt(0) - 87 : Number(j);
                        j = '+' == i.charAt(k + 1) ? a >>> j : a << j;
                        a = '+' == i.charAt(k) ? a + j & 4294967295 : a ^ j;
                    }
                    a ^= Number(e[1]) || 0;
                    0 > a && (a = (a & 2147483647) + 2147483648);
                    a %= 1E6;
                    return a.toString() + '.' + (a ^ h);
                },

                // Cookie操作
                setCookie: function(name, value, options) {
                    options = options || {};
                    if (value === null) {
                        value = '';
                        options.expires = -1;
                    }
                    var expires = '';
                    if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
                        var date;
                        if (typeof options.expires == 'number') {
                            date = new Date();
                            date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
                        } else {
                            date = options.expires;
                        }
                        // use expires attribute, max-age is not supported by IE
                        expires = '; expires=' + date.toUTCString();
                    }
                    var path = options.path ? '; path=' + options.path : '';
                    var domain = options.domain ? '; domain=' + options.domain : '';
                    var secure = options.secure ? '; secure' : '';
                    var c = [name, '=', encodeURIComponent(value)].join('');
                    var cookie = [c, expires, path, domain, secure].join('');
                    document.cookie = cookie;
                },
                getCookie: function(name) {
                    var cookieValue = null;
                    if (document.cookie && document.cookie != '') {
                        var cookies = document.cookie.split(';');
                        for (var i = 0; i < cookies.length; i++) {
                            var cookie = cookies[i].trim();
                            // Does this cookie string begin with the name we want?
                            if (cookie.substring(0, name.length + 1) == (name + '=')) {
                                cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                                break;
                            }
                        }
                    }
                    return cookieValue;
                },

                // 美化数据
                sanitize: function () {
                    // 代码高亮
                    if ($('.entry-content').length) {
                        $('.entry-content p:first').addClass('lead');
                        $('.entry-content').css('font-size', '16px');
                        $('.entry-content pre').addClass('prettyprint linenums');
                        window.prettyPrint && window.prettyPrint();
                        $('.entry-content pre.prettyprint ol.linenums>li').attr('style', 'list-style-type: decimal;white-space: pre-wrap');
                    }

                    // 点击数更新
                    if ($('.post-views').length) {
                        var views = parseInt(render.data.article_views);
                        var store = [];
                        try {
                            store = JSON.parse(render.getItem(render.data.langs && render.data.langs.length ? 'multiPostViews' : 'postViews') || '[]');
                        } catch (e) {
                            render.removeItem(render.data.langs && render.data.langs.length ? 'multiPostViews' : 'postViews');
                            store = [];
                        }
                        // var obj = store.find(function (item) {
                        //     return item.id == render.data.article_id;
                        // });
                        // 兼容IE10
                        var obj = null;
                        for (var i = 0; i < store.length; i++) {
                            if (store[i].id == render.data.article_id) {
                                obj = store[i];
                            }
                        }
                        if (obj) {
                            // 拒绝2小时内恶意刷新
                            if (+new Date() - obj.timestamp >= 2 * 3600 * 1000) {
                                obj.views = views + 1;
                                obj.timestamp = +new Date();
                                obj.lang = render.data.lang;
                                render.setItem(render.data.langs && render.data.langs.length ? 'multiPostViews' : 'postViews', JSON.stringify(store));
                                $.post(render.data.site_url + (render.data.lang == 'zh-CN' ? '' : '/' + render.data.lang) + '/api/ajax/views.html', { id: render.data.article_id, views: views }, 'json');
                            }
                            $('.post-views').html(obj.views);
                        } else {
                            // 首次执行
                            store.push({ id: render.data.article_id, views: views + 1, timestamp: +new Date(), lang: render.data.lang });
                            render.setItem(render.data.langs && render.data.langs.length ? 'multiPostViews' : 'postViews', JSON.stringify(store));
                            $('.post-views').html(views + 1);
                            $.post(render.data.site_url + (render.data.lang == 'zh-CN' ? '' : '/' + render.data.lang) + '/api/ajax/views.html', { id: render.data.article_id, views: views }, 'json');
                        }
                    }

                    // 收藏文章
                    if ($('.entry-content').length) {
                        var store = [];
                        try {
                            store = JSON.parse(render.getItem(render.data.langs && render.data.langs.length ? 'multiPostFavorites' : 'postFavorites') || '[]');
                        } catch (e) {
                            render.removeItem(render.data.langs && render.data.langs.length ? 'multiPostFavorites' : 'postFavorites');
                            store = [];
                        }
                        // var obj = store.find(function (item) {
                        //     return item.id == render.data.article_id;
                        // });
                        // 兼容IE10
                        var obj = null;
                        for (var i = 0; i < store.length; i++) {
                            if (store[i].id == render.data.article_id) {
                                obj = store[i];
                            }
                        }
                        if (obj) {
                            $('.btn-favorite').removeClass('btn-warning').attr('title', (render.data.localize.favorite_cancel ? render.data.localize.favorite_cancel : '取消收藏')).html('<span class="glyphicon glyphicon-star" aria-hidden="true"></span> ' + (render.data.localize.favorite_success ? render.data.localize.favorite_success : '收藏成功'));
                        } else {
                            $('.btn-favorite').addClass('btn-warning').attr('title', (render.data.localize.favorite_article ? render.data.localize.favorite_article : '收藏文章')).html('<span class="glyphicon glyphicon-star-empty" aria-hidden="true"></span> ' + (render.data.localize.favorite_article ? render.data.localize.favorite_article : '收藏文章'));
                        }
                    }

                    // 点赞
                    if ($('.post-likes').length) {
                        var likes = parseInt(render.data.article_likes);
                        var store = [];
                        try {
                            store = JSON.parse(render.getItem(render.data.langs && render.data.langs.length ? 'multiPostLikes' : 'postLikes') || '[]');
                        } catch (e) {
                            render.removeItem(render.data.langs && render.data.langs.length ? 'multiPostLikes' : 'postLikes');
                            store = [];
                        }
                        // var obj = store.find(function (item) {
                        //     return item.id == render.data.article_id;
                        // });
                        // 兼容IE10
                        var obj = null;
                        for (var i = 0; i < store.length; i++) {
                            if (store[i].id == render.data.article_id) {
                                obj = store[i];
                            }
                        }
                        if (obj) {
                            $('.btn-likes').addClass('disabled').addClass('btn-disabled');
                        }
                    }

                    // 更新点赞收藏文章数量
                    if ($('.panel-pages').length) {
                        var favorites = [];
                        try {
                            favorites = JSON.parse(render.getItem(render.data.langs && render.data.langs.length ? 'multiPostFavorites' : 'postFavorites') || '[]');
                        } catch (e) {
                            render.removeItem(render.data.langs && render.data.langs.length ? 'multiPostFavorites' : 'postFavorites');
                            favorites = [];
                        }
                        var likes = [];
                        try {
                            likes = JSON.parse(render.getItem(render.data.langs && render.data.langs.length ? 'multiPostLikes' : 'postLikes') || '[]');
                        } catch (e) {
                            render.removeItem(render.data.langs && render.data.langs.length ? 'multiPostLikes' : 'postLikes');
                            likes = [];
                        }
                        // var findFavorites = favorites.filter(function (item) {
                        //     return item.lang == render.data.lang;
                        // });
                        // var findLikes = likes.filter(function (item) {
                        //     return item.lang == render.data.lang;
                        // });
                        // 兼容IE10
                        var findFavorites = [];
                        for (var i = 0; i < favorites.length; i++) {
                            if (favorites[i].lang == render.data.lang) {
                                findFavorites.push(favorites[i]);
                            }
                        }
                        var findLikes = [];
                        for (var i = 0; i < likes.length; i++) {
                            if (likes[i].lang == render.data.lang) {
                                findLikes.push(likes[i]);
                            }
                        }
                        $('#page-favorites').text(findFavorites.length);
                        $('#page-likes').text(findLikes.length);
                        $('.panel-pages .list-group .list-group-item').each(function (i, elem) {
                            $(elem).data('slug') == 'page-favorites' && $(elem).find('.badge').text(findFavorites.length);
                            $(elem).data('slug') == 'page-likes' && $(elem).find('.badge').text(findLikes.length);
                        });
                    }

                    // 获取收藏点赞文章列表
                    if ($('#page-lists').length) {
                        var slug = $('#page-lists').data('slug');
                        var p = 1;
                        var url_part = location.href.slice(location.href.lastIndexOf('/') + 1);
                        var match = url_part.match(/^page-(\d+).html/);
                        if (match) p = match[1];
                        var storeName = slug == 'page-favorites' ? (render.data.langs && render.data.langs.length ? 'multiPostFavorites' : 'postFavorites') : (slug == 'page-likes' ? (render.data.langs && render.data.langs.length ? 'multiPostLikes' : 'postLikes') : '');
                        if (storeName == '') return false;
                        var store = [];
                        try {
                            store = JSON.parse(render.getItem(storeName) || '[]');
                        } catch (e) {
                            render.removeItem(storeName);
                            store = [];
                        }
                        // store = store.filter(function (item) {
                        //     return item.lang == render.data.lang;
                        // });
                        // var ids = store.map(function (item) {
                        //     return item.id;
                        // });
                        // 兼容IE10
                        var ids = [];
                        var newArr = [];
                        for (var i = 0; i < store.length; i++) {
                            if (store[i].lang == render.data.lang) {
                                ids.push(store[i].id);
                                newArr.push(store[i]);
                            }
                        }
                        store = newArr;
                        $.ajax({
                            type: 'POST',
                            url: render.data.site_url + (render.data.lang == 'zh-CN' ? '' : '/' + render.data.lang) + '/api/ajax/page_lists.html',
                            data: {
                                ids: ids,
                                p: p,
                                slug: slug,
                            },
                            dataType: 'json',
                            cache: false,
                            beforeSend: function () {
                                $('<div id="loading" class="text-center"><i class="icon-loading"></i> Loading...</div>').appendTo('#page-lists');
                            },
                            success: function (res) {
                                if (res.code) {
                                    $('#page-lists #loading').html(res.msg)
                                    setTimeout(function () {
                                        $('#page-lists #loading').html('').remove();
                                    }, 3000);
                                    return false;
                                }
                                $('#page-lists #loading').html('').remove();
                                $('#page-counts').text(res.count);
                                var list = JSON.parse(res.data || '[]');
                                for (var i in list) {
                                    $(list[i]).appendTo('#page-lists');
                                }
                                res.count && $(res.pager).appendTo('#page-lists');
                                render.lazyLoad();
                            },
                            error: function (XMLHttpRequest, textStatus) {
                                $('#page-lists #loading').html(textStatus + ': ' + XMLHttpRequest.status);
                                setTimeout(function () {
                                    $('#page-lists #loading').html('').remove();
                                }, 3000);
                            }
                        });
                    }

                    // 语音播报
                    if ($('.entry-content').length && render.data.voice_read == '1') {
                        render.nodes = [];
                        render.offLine = false;
                        var ignore = ['STYLE', 'SCRIPT', 'IFRAME', 'VIDEO', 'AUDIO', 'SOURCE', 'PRE', 'CODE', 'IMG', 'BR', 'HR', 'TABLE', 'FORM', 'FIELDSET', 'LEGEND', 'LABEL', 'INPUT', 'TEXTAREA', 'SELECT', 'BUTTON'];
                        $('<meta name="referrer" content="same-origin">').appendTo('head').remove();
                        $('.entry-content').contents().each(function (i, node) {
                            if (ignore.indexOf(node.tagName) === -1 && node.textContent.trim()) {
                                render.nodes.push({ node: node, index: i });
                            }
                        });
                        if ('speechSynthesis' in window) {
                            var i = 0;
                            var timer = setInterval(function () {
                                i++;
                                var voices = window.speechSynthesis.getVoices();
                                if (voices.length || i > 10) {
                                    clearInterval(timer);
                                    for (var j = 0; j < voices.length; j++) {
                                        if (voices[j].lang.indexOf(render.data.lang) !== -1) {
                                            render.offLine = voices[j].lang;
                                            break;
                                        }
                                    }
                                }
                            }, 100);
                        }
                    }

                    // 字母图像
                    if ($('.media .media-object.avatar').length) {
                        $('.media .media-object.avatar').each(function () {
                            if ($(this).attr('src').indexOf(render.data.site_url) == -1) {
                                $(this).attr('src', render.generateAvatar($(this).attr('alt')));
                            }
                        });
                    }

                    // 回顶与播放
                    $('body .fixed-bottom').css({
                        position: 'fixed',
                        right: 'calc(' + ($(window).width() > 1280 ? ($(window).width() - $('.container').outerWidth()) / 2 : 50) + 'px - 40px)',
                        bottom: '30px',
                        width: '40px',
                        textAlign: 'center',
                        color: '#fff',
                        cursor: 'pointer',
                        zIndex: 10,
                        display: 'none'
                    });
                    $('body .fixed-bottom .play-btn, body .fixed-bottom .pause-btn, body .fixed-bottom .back-top').css({
                        height: '40px',
                        lineHeight: '40px',
                        background: 'rgba(0,0,0,.3)',
                        borderRadius: '50%'
                    });

                    // 循环轮播
                    $('#carousel-example-generic').carousel('cycle');

                    // 社会化分享
                    if ($('.entry-content').length) {
                        var config = {
                            url                 : location.protocol.match(/http:|https:/i) ? location.href : render.data.site_url + render.data.article.link, // 网址，默认使用 window.location.href
                            source              : render.data.site_url, // 来源（QQ空间会用到）, 默认读取head标签：<meta name="site" content="http://overtrue" />
                            title               : render.data.article.title, // 标题，默认读取 document.title 或者 <meta name="title" content="share.js" />
                            description         : (render.data.article.description ? render.data.article.description : render.cutstr(render.data.article.content.replace(/<[^>]*>/g, ' ').replace(/\s+/g, ' '), 140)), // 描述, 默认读取head标签：<meta name="description" content="PHP弱类型的实现原理分析" />
                            // image               : '', // 图片, 默认取网页中第一个img标签
                            // sites               : ['qzone', 'qq', 'weibo','wechat', 'douban'], // 启用的站点
                            // disabled            : ['google', 'facebook', 'twitter'], // 禁用的站点
                            // wechatQrcodeTitle   : "微信扫一扫：分享", // 微信二维码提示文字
                            // wechatQrcodeHelper  : '<p>微信里点“发现”，扫一下</p><p>二维码便可将本文分享至朋友圈。</p>',
                        }
                        window.socialShare && window.socialShare('#social-share', config);
                    }
                }
            }
            render.init();
        });
    </script>
</body>

</html>